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.
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.
- 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.
- 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.
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.
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.
- 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.
- 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.
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.
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
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.
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.
When copying file pages back and forth, we need both dst and src
offsets since the cursor offset and read/write buffer page offsets
are different. This is now fixed.
Also done some mods to close().