Commit Graph

33 Commits

Author SHA1 Message Date
Bahadir Balban
0db0f7e334 Multiple updates on sleeping, vma dropping and thread suspend.
- Updated sleeping paths such that a task is atomically put into
  a runqueue and made RUNNABLE, or removed from a runqueue and made SLEEPING.
- Modified vma dropping sources to handle both copy_on_write() and exit() cases
  in a common function.
- Added the first infrastructure to have a pager to suspend a task and wait for
  suspend completion from the scheduler.
2008-10-13 12:22:10 +03:00
Bahadir Balban
f6d0a79298 New scheduler and interruptible blocking.
A new scheduler replaces the old one.
  - There are no sched_xxx_notify() calls that ask scheduler to change task state.
  - Tasks now have priorities and different timeslices.
  - One second interval is distributed among processes.
  - There are just runnable and expired queues.
  - SCHED_GRANULARITY determines a maximum running boundary for tasks.
  - Scheduler can now detect a safe point and suspend a task.

Interruptible blocking is implemented.
  - Mutexes, waitqueues and ipc are modified to have an interruptible nature.
  - Sleep information is stored on the ktcb. (which waitqueue? etc.)
2008-10-01 12:43:44 +03:00
Bahadir Balban
c54d505709 Changes towards exit. Need to fix thread suspend first. 2008-09-27 22:15:34 +03:00
Bahadir Balban
1ea21d84bd Updated test0 with a forktest. Fixed timeslices. Updated kmem usage calculations.
- test0 now forks 16 tasks that each modify a global variable.
- scheduler now gives 1/10th of a second per task. It also does not increase timeslice
  of a task that has scheduled.
- When a memory is granted to the kernel, the distribution of this memory to memcaches
  was calculated in a complicated way. This is now simplified.
2008-09-17 15:19:37 +03:00
Bahadir Balban
30de876a6c Added MR #define place holders so that these are used instead of real register names 2008-09-15 18:27:41 +03:00
Bahadir Balban
df2317e7aa exchange_registers(), modified thread_control calls seem to work
- Fixed do_mmap() so that it returns mapped address, and various bugs.
- A child seems to fork with new setup, but with incorrect return value.
  Need to use and test exregs() for fork + clone.
- Shmat searches an unmapped area if input arg is invalid, do_mmap()
  should do this.
2008-09-15 15:59:44 +03:00
Bahadir Balban
4fb5277123 Towards finishing exchange_registers()
- Added mutex_trylock()
- Implemented most of exchange_registers()
- thread_control() now needs a lock for operations that can modify thread context.
- thread_start() does not initialise scheduler flags, now done in thread_create.

TODO:
- Fork/clone'ed threads should retain their context in tcb, not syscall stack.
- exchange_registers() calls in userspace need cleaning up.
2008-09-13 18:07:00 +03:00
Bahadir Balban
002fe79a54 Added thread group identification to c0 and libl4
tgid will be used when threads will be created in same address space.
2008-09-09 15:39:56 +03:00
Bahadir Balban
afc0599d49 Saving all registers in syscall so that return from fork is easier.
Child needs rewound function stack in order to reach registers r9-r12
that have original userspace values. But we jump to return_from_syscall
without rewinding the stack. Therefore to ease context restore, we save
r9-r12 on the stack as well upon syscall entry.
2008-09-01 16:19:03 +03:00
Bahadir Balban
4ffdb45550 Fixed 2 more fork issues
Added setting of spsr for the new task.
Added newly created task into mm0's global task list.
2008-08-27 22:27:53 +03:00
Bahadir Balban
476bac5142 Cleaned up all compile errors. 2008-08-25 16:59:00 +03:00
Bahadir Balban
3ce220f062 Changes to make sure after a fork a child process can safely return.
This copies the parent kernel stack to child only for the part where
the previous context is saved. Then the child registers are modified
so that it would begin execution from returning of the system call.
2008-08-21 16:21:08 +03:00
Bahadir Balban
69db3a04c0 Towards implementing fork.
Issue is that shadow object references from original objects are into
the links rather than the objects.
2008-08-19 18:03:23 +03:00
Bahadir Balban
a87914910c Added a new system call sys_timer.
sys_timer accumulates timer ticks into seconds, minutes, hours and days.
It's left to the user to calculate from days into a date. It is not yet
known if the calculation is even roughly correct.

Reduced 2 kmem_reclaim/grant calls into one kmem_control call.
2008-04-18 00:46:29 +01:00
Bahadir Balban
35d2d275b6 Multiple above-minor updates.
- fixed is_err(x), was evaluating x twice, resulting in calling a
function x twice.

- Divided task initialisation into multiple parts.
- MM0 now creates a tcb for itself and maintains memory regions of its own.
- MM0's tcb is used for mmapping other tasks' regions. MM0 mmaps and prefaults
  those regions, instead of the typical mmap() and fault approach used by
  non-pager tasks.
  For example there's an internal shmget_shmat() path to map in other tasks'
  shm utcbs. Those mappings are then prefaulted into mm0's address space using
  the default fault handling path.

- FS0 now reads task data into its utcb from mm0 via a syscall.
  FS0 shmat()s to utcbs of other tasks, e.g. mm0 and test0.

  FS0 then crashes, that is to be fixed and where this commit is left last.
2008-03-24 00:34:14 +00:00
Bahadir Balban
509e949983 Added a few vm_object debug functions. Fixed few bugs.
Next issues: For every read fault, the fault must traverse the
vma's object stack until the page is found. The problem was that
we were only searching the first object, that object was a writable
shadow, and the shadow didn't have the read-only page, and the 0
return value was interpreted with IS_ERR() and failed, so address
0 was mapped into the location, and QEMU blew off.
2008-03-16 18:57:26 +00:00
Bahadir Balban
617d24b4f0 Modified task initialisation so that stack now comes beneath the environment
Environment is backed by a special per-task file maintained by mm0 for each task.
This file is filled in by the env pager, by simple copying of env data into the
faulty page upon a fault. UTCB and all anon regions (stack) could use the same
scheme.

Fixed IS_ERR(x) to accept negative values that are above -1000 for errors. This
protects against false positives for pointers such as 0xE0000000.

	modified:   include/l4/generic/scheduler.h
	modified:   include/l4/macros.h
	modified:   src/arch/arm/exception.c
	modified:   tasks/fs0/include/linker.lds
	modified:   tasks/libl4/src/init.c
	modified:   tasks/libposix/shm.c
	new file:   tasks/mm0/include/env.h
	modified:   tasks/mm0/include/file.h
	new file:   tasks/mm0/include/lib/addr.h
	deleted:    tasks/mm0/include/lib/vaddr.h
	modified:   tasks/mm0/include/task.h
	new file:   tasks/mm0/include/utcb.h
	new file:   tasks/mm0/src/env.c
	modified:   tasks/mm0/src/fault.c
	modified:   tasks/mm0/src/file.c
	modified:   tasks/mm0/src/init.c
	new file:   tasks/mm0/src/lib/addr.c
	modified:   tasks/mm0/src/lib/idpool.c
	deleted:    tasks/mm0/src/lib/vaddr.c
	modified:   tasks/mm0/src/mmap.c
	modified:   tasks/mm0/src/shm.c
	modified:   tasks/mm0/src/task.c
	new file:   tasks/mm0/src/utcb.c
	modified:   tasks/test0/include/linker.lds
2008-02-29 01:43:56 +00:00
Bahadir Balban
dce3a9a47c Merged some libl4 utcb headers, moved mr defs to kernel message.h
Headers 3 headers related to message registers and utcbs are now merged under
utcb.h in libl4. Some message register definitions used by the kernel are now
moved into kernel's glue/message.h. This avoids the duplication of same
definitions. Also the total number of mregs are now determined by arch-specific
kernel header, which is good.
2008-02-11 11:45:21 +00:00
Bahadir Balban
e0492d672f Kernel inspects and sets sender id instead of userspace.
Modified ipc handling so that from now on the kernel inspects and sets
the sender id if the receiver is receiving from L4_ANYTHREAD. This posed
a security problem since the receiver could not trust the sender for
sender information.
2008-02-11 11:11:17 +00:00
Bahadir Balban
cd170c1b7c Changed unit macro to use section attribute directly.` 2008-02-09 14:33:37 +00:00
Bahadir Balban
cc23568629 Added locking to id pool allocation and free. 2008-02-09 14:30:03 +00:00
Bahadir Balban
ba0e3ada21 Few more fixes.
Boot files and tasks are now initialised together. Theads can ask for particular
space and thread ids, if they're unused. This enables us to get predefined ids for
known tasks such as the VFS task.

Fixes to README
Other minor fixes.
2008-02-09 14:24:49 +00:00
Bahadir Balban
4f2e1d3e94 Fixed various minor issues.
Tag setting before ipc via l4 libraries don't seem to work, whereas
c0 internally generated ipcs do it correctly.
2008-02-05 18:30:11 +00:00
Bahadir Balban
a82cdd3456 User pointer validity checks.
Added routines that check whether a user pointer is accessible by the kernel,
and if not ask the pager to map-in those pages. I haven't implemented yet the
bit that asks the pager for paging-in.
2008-02-05 15:41:14 +00:00
Bahadir Balban
70d5ff33cd This patch adds ipc_sendrecv() and opens the way for client/server communication.
ipc_sendrecv() replaces ipc_sendwait() which was flawed. See ipc_sendrecv() for
how client/server communication works. Tested with page faults where the kernel
does an ipc_sendrecv() to faulty thread's pager and the pager successfully handles
the request, and returns back the result, which effectively restarts the faulty
thread.
2008-02-04 21:03:51 +00:00
Bahadir Balban
ca5229ff88 Fixed the problem that mm0 would read registers from actual MR0
instead of MR_UNUSED_START.
2008-02-04 19:35:13 +00:00
Bahadir Balban
ddba7536cb Remove the mechanism for blocking tasks from doing ipc.
Removed previously implemented but untested mechanism of blocking tasks
from doing ipc to certain tasks using certain tags. This is to be considered
for future implementation.
2008-02-04 16:58:05 +00:00
Bahadir Balban
938672f7c9 Changed the virt-to-phys debug breakpoint name to break_virtual
Changed l4id_t type to integer to recognise negative id values like L4_ANYTHREAD.
Added an extremely simple script that cleans and builds everything in right order.

Increased boot pmds by one:
This is due to the fact that if the 1MB initial allocation area of the kernel is
not 1MB-aligned, it is ought to be mapped from the middle of one MB to next,
which requires 2 pmds.

	modified:   .gdbinit
	modified:   README
	new file:   buildall.sh
	modified:   include/l4/arch/arm/types.h
	modified:   include/l4/generic/scheduler.h
	modified:   loader/kernel.S
	modified:   loader/main.c
	modified:   loader/mylink.lds
	modified:   loader/start.axf.S
	modified:   src/glue/arm/init.c
	modified:   src/glue/arm/memory.c
	modified:   tasks/fs0/src/bdev.c
	modified:   tasks/mm0/include/kdata.h
	modified:   tasks/mm0/include/vm_area.h
	modified:   tasks/mm0/src/init.c
	modified:   tasks/mm0/src/task.c
	modified:   tools/ksym_to_lds.py
	modified:   tools/l4-qemu
2008-02-04 16:44:11 +00:00
Bahadir Balban
cab2e8bdd3 Finished adding untested bare functionality vfs
Finished adding untested shm syscalls.
Finished adding untested l4 send/recv helpers

Everything compiles. Now going to fix lots of bugs ;-)
2008-02-03 17:42:38 +00:00
Bahadir Balban
05e9028e90 Some more minor changes. 2008-01-22 13:26:19 +00:00
Bahadir Balban
efd797c678 Added two gitignore files to git. 2008-01-14 13:36:47 +00:00
Bahadir Balban
7a388f22b7 Removed all ignorable files from git.
Previously python hex() would put an extra 'L' after printing out the
value and this would be trimmed in readelf.py. Now it doesn't seem to
do that so the lsd of the number was trimmed. This patch fixes that.
2008-01-14 12:23:40 +00:00
Bahadir Balban
e2b791a3d8 Initial commit 2008-01-13 13:53:52 +00:00