Commit Graph

154 Commits

Author SHA1 Message Date
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
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
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
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
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
fd787479c3 Fixed minor faults during close path.
FIXME:
write/close/open/read sequence does not read the initially written data.
Investigate.
2008-05-23 05:42:26 +00:00
Bahadir Balban
6be310f460 Added sys_close and sys_fsync
Untested.
2008-05-23 03:59:18 +00:00
Bahadir Balban
00b47117b0 Added sys_stat, sys_fstat and their libposix glue. 2008-05-22 11:21:27 +00:00
Bahadir Balban
bd8b182f1b Added syscall to update filestats (size) from pager.
After flushing written/truncated pages, stats are updated
so that vfs is synced with new file info such as its size.
2008-05-21 10:23:11 +00:00
Bahadir Balban
5efece98cd More changes 2008-05-03 15:04:16 +01:00
Bahadir Balban
0557fa8910 Gotta find a way to pass on updated file size before write_file_pages. 2008-04-26 01:03:11 +01:00
Bahadir Balban
f183b3c15e Still towards close/flush. 2008-04-25 23:06:23 +01:00
Bahadir Balban
c9b9f9d111 Towards sys_close()/sys_flush() 2008-04-25 22:14:59 +01:00
Bahadir Balban
488d9e6271 Fixed the issue that page copy offsets were not correct.
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().
2008-04-25 17:07:49 +01:00
Bahadir Balban
ba725168a0 Fixed lseek. Updates to sys_read/sys_write
read and write are both called by test0. But they don't yet
work as expected. An error is in one or both. To be investigated.
2008-04-24 00:09:49 +01:00
Bahadir Balban
0629ba3c1a sys_write() "seems to" work. Also added support for sys_lseek(). 2008-04-23 14:14:45 +01:00
Bahadir Balban
59bdaf22ec Towards user buffer checking 2008-04-22 14:18:12 +01:00
Bahadir Balban
1270cfe3b3 open file descriptor references to vm files weren't properly initialised.
This fixes the issue. sys_read/write yet to be inspected.
2008-04-22 01:41:18 +01:00
Bahadir Balban
e8bb529dcb Now we save/restore utcb registers if we do a second ipc before returning the first. 2008-04-22 00:30:07 +01:00
Bahadir Balban
80470e2581 Adding reply phase to pager_sys_open()
So that open() errors on pager's side can be noticed by vfs.
2008-04-21 15:30:40 +01:00
Bahadir Balban
a674cf2b27 Recompiled with write_cache_pages(). Implementation to be re-evaluated. 2008-04-21 00:31:16 +01:00
Bahadir Balban
e3cc14515c mm0 compiles, still previous issues on. 2008-04-20 23:34:25 +01:00
Bahadir Balban
d8d65a6301 Efforts towards sys_write.
- Added logic to calculate which pages are in the file and which are new
  for writing.
- Nearly finished the template for sys_write.
- Need to implement write_cache_pages().
- Need to distinguish dirty/clean pages and implement flushing dirty
  pages back to vfs.
2008-04-20 17:33:05 +01:00
Bahadir Balban
9992d100d7 Few fixes in libposix error checking.
size_t is a non-negative type and negative error checking didn't work. Now fixed.
Fixed various issues with reading file pages in the sys_read() path.
2008-04-20 02:12:53 +01:00
Bahadir Balban
8b3fedc18d Towards working sys_read/sys_write. 2008-04-19 15:42:13 +01:00
Bahadir Balban
9f4e400fed Minor updates to README 2008-04-19 12:28:49 +01:00
Bahadir Balban
df0eccf7b3 A file can be created.
Now up to sys_write() in pager, which needs to be filled in.
2008-04-19 01:27:41 +01:00
Bahadir Balban
ce26835968 fd wasn't returned in reorganised sys_open. Fixed. 2008-04-19 00:55:11 +01:00
Bahadir Balban
8c4c436925 Reorganised sys_open.
vfs_create and mknod now returns the newly created vnode.
(which might be used by upper layers).
2008-04-19 00:40:48 +01:00
Bahadir Balban
f7163b7e93 Added file io test to test0. Added close call to libposix. 2008-04-18 21:17:09 +01:00
Bahadir Balban
cff7a505e8 Changed time representation to posix style struct timeval/ gettimeofday. 2008-04-18 13:58:37 +01:00