Commit Graph

195 Commits

Author SHA1 Message Date
Bahadir Balban
cb9c5438e2 Back to forked tests with test0 2008-09-17 11:06:28 +03:00
Bahadir Balban
380c6390b7 Fixed 2 bugs with broken memfs read()
read end page boundary was off by one.
memcpy routine had an extra dereference for src ptr.
	modified:   src/memfs/file.c
2008-09-17 11:03:42 +03:00
Bahadir Balban
05e9b43722 test0 tests now don't fork, they compare read/write strings. 2008-09-17 09:51:52 +03:00
Bahadir Balban
86e752be59 Removed find_task(sender) + l4_ipc_return(ret) from fs0 syscalls.
Both moved to topmost request handler so syscalls need not call them.
2008-09-16 22:19:54 +03:00
Bahadir Balban
ab67ee4cda Added l4_restore_ipcregs() to all error return paths for stacked ipc calls 2008-09-16 20:25:11 +03:00
Bahadir Balban
a413b19842 Moved all find_task(sender) calls into topmost ipc handler.
System calls now need not search for the tcb they are serving for.
2008-09-16 20:11:24 +03:00
Bahadir Balban
2e94a78253 Cleanup: Moved all l4_ipc_return() calls to uppermost handler routine.
Now all system calls can simply return their final values and they
will be sent to client parties from a single location. Should have had this
simple cleanup a long time ago.
2008-09-16 18:56:18 +03:00
Bahadir Balban
270cead377 Removed various printfs from fs0 path lookup etc. 2008-09-16 17:41:47 +03:00
Bahadir Balban
510852b8b8 Redesigned sys_open call
fs0 used to receive open() requests and notify pager about them via a syscall ipc.
This caused deadlocks because normally request flow is mm0 -> fs0 on all other calls.
The solution was to have mm0 ask and validate file descriptors from fs0 on the first
request instance that involved that file descriptor. By this method we delay the
validation of the fd until its first use, and avoid deadlock. It also fits well with
the lazy request handling design philosophy.
2008-09-16 15:50:00 +03:00
Bahadir Balban
398bc0c914 debug aborts commented out 2008-09-16 11:31:44 +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
4d1b649465 Fix to exregs.c functions 2008-09-15 18:16:02 +03:00
Bahadir Balban
9c2c9676e8 Added exregs_set_mr() function
Moved all exregs-related calls to libl4 since these are part of the L4 api.
2008-09-15 17:57:09 +03:00
Bahadir Balban
b7d1e46138 README typo fix 2008-09-15 16:06:22 +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
0b3ab05a98 Some minor changes
Need to reimplement exchange_registers
2008-09-12 10:47:36 +03:00
Bahadir Balban
af03975dc1 Towards adding sys_clone()
Stopped working on self_spawn() - going to finish clone() syscall first.
Arch-specific clone() library call that does ipc() and cloned child setup.
- Need to finish thread_create() that satisfy clone() necessities. i.e. setting up its stack.
  Question: Does the pager (and thus the microkernel) have to explicitly set SP_USR?
  Once the call is known to be successful, the library could set it.
2008-09-11 16:56:41 +03:00
Bahadir Balban
fc51512438 Added MAP_GROWSDOWN feature to do_mmap. Fixed sys_mmap return. 2008-09-10 12:43:49 +03:00
Bahadir Balban
7b9e02d04b Tidying up task.c
Moved boot functions to init.c
Moved copy_tcb to tcb_create, handling multiple cases with fork and clone.
2008-09-10 11:56:54 +03:00
Bahadir Balban
d7de9aa643 Shared tcb structures are made independent
For clone, file descriptor and vm area structures need to be
separate from the tcb and reached via a pointer so that they
can be shared among multiple tcbs.
2008-09-09 22:17:42 +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
89d774f7fa Mixed changes
- Added automatic utcb map/prefaulting of forked tasks for fs0
  so that it does not need to explicitly request those tasks from mm0.
  Eliminating fs0 requests to mm0 reduce deadlock possibilities.

- Replaced kmalloc with a public malloc implementation because of a bug in kmalloc.
- Fixed a kfree bug. default_release_pages was trying to free page_array pages.
2008-09-09 13:36:42 +03:00
Bahadir Balban
68a4e78e66 Greatly simplified page allocator.
Made most changes for alloc_page()
2008-09-06 12:55:47 +03:00
Bahadir Balban
6c1da12fec Mixed changes
- Adding prefaulting of fs0 to avoid page fault deadlocks.
- Fixed a bug that a vmo page_cache equivalence would simply drop a link to
  an original vmo, even if the vmo could have more pages outside the page cache,
  or if the vmo was not a shadow vmo.
- Fixed a bug with page allocator where recursion would corrupt global variables.
- Now going to fix or re-write a simpler page allocator that works.
2008-09-06 11:15:41 +03:00
Bahadir Balban
f6deedff87 Update to README 2008-09-01 19:27:16 +03:00
Bahadir Balban
a5fa48bc2f When copying page tables, added excluding common kernel entries.
Normally common kernel entries in 2nd level page table need not get
copied to new tasks since those entries will be used commonly by all tasks.
On fork, we were copying those unnecessarily.
2008-09-01 17:26:49 +03:00
Bahadir Balban
fb8d8f4bb9 README update 2008-09-01 16:44:33 +03:00
Bahadir Balban
0a9dede8f7 Fix to fork return value issue.
Mistakenly returned child pid to pager in thread_create. This is fixed.
Its not the pager but the forking task that needs this value.
2008-09-01 16:27:44 +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
021bd6bc99 Fix to printf 2008-08-29 13:24:57 +03:00
Bahadir Balban
895651b778 Cleaner debug messages for fault handling. 2008-08-29 13:07:28 +03:00
Bahadir Balban
63e9d059c8 More updates to vm object handling.
Added a list of links for vm objects so they can follow
the links that point at them.

More succinct handling of the case where a vm object
is dropped. Now depending on the object's number of link
references and shadow references, upon a drop it could
either be merged, deleted or kept.

Added opener reference count for vm files. Now files
have opener count, objects have shadow and link count.
Link count is also meaningful for how many tasks have
mmap'ed that object.
2008-08-29 12:35:07 +03:00
Bahadir Balban
2217349b60 Fixed 2 bugs in kmalloc. (phew)
When allocating a new area, the alignment calculation of new area
structure was wrong. Hopefully this is now fixed. The original function
with bad alignment was preserved.

When freeing a new area and merging it with adjacent areas, pointer
to previous area was mistakenly used instead of pointer to next.

	modified:   tasks/libmem/kmalloc/kmalloc.c
2008-08-29 12:32:59 +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
dad1d2d792 When creating a new thread, forgot to set its syscall_args * pointer. 2008-08-27 14:52:06 +03:00
Bahadir Balban
f1b3a9b95d Fixed a shadow object search logic error.
R/W shadow objects must be made read-only during a fork.
When searching for a writeable shadow object, it can only be the first
object on the vma object chain, therefore not traversing the object
chain and checking only the first object is sufficient.
2008-08-27 14:08:32 +03:00
Bahadir Balban
1ca3fce49b Changes in README. Fix to thread_control() reading wrong syscall argument register. 2008-08-27 13:39:16 +03:00
Bahadir Balban
476bac5142 Cleaned up all compile errors. 2008-08-25 16:59:00 +03:00
Bahadir Balban
cdfaa4bbe9 Fix to parent return value 2008-08-22 01:50:54 +03:00
Bahadir Balban
1a90b655c7 Added child utcb initialisation to fork call implementation in libposix. 2008-08-22 00:26:19 +03:00
Bahadir Balban
1d15821acb Added ipc to notify vfs about a forked child.
TODO: Need to ensure child shmat()s its own utcb
after a fork (possibly in libposix/fork.c)
2008-08-22 00:11:06 +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
dada3e0b2c Added copy_vma() function.
Sorting out return_from_fork() and kernel stack setup for the child.
2008-08-21 12:18:38 +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
f436b44e81 Changes in the README, changes to fork template. 2008-08-16 13:01:18 +03:00
Bahadir Balban
d434ad4b40 Changes towards adding clone/fork
new file:   src/clone.c
2008-08-05 16:56:55 +03:00
Bahadir Balban
d1170211e3 Commented out printfs for pager/vfs interaction 2008-05-30 11:18:16 +03:00
Bahadir Balban
f561d885d5 Flushing pages to vfs will work, but the issue is that while vfs is
serving mm0, if it page faults, system deadlocks because mm0 is waiting to be served by vfs.

FIX: To fix this, mm0 will need to fork itself and keep a separate thread solely for
page fault handling.
2008-05-28 23:37:41 +03:00
Bahadir Balban
98888a94b5 Modified scripts 2008-05-27 10:17:46 +03:00