Commit Graph

246 Commits

Author SHA1 Message Date
Bahadir Balban
b0291fa075 Added the LICENSE file for GPL v3. 2008-11-09 12:22:48 +02:00
Bahadir Balban
513d5aaac8 Added exit.c that seemed to be out of tree. 2008-11-09 11:42:10 +02:00
Bahadir Balban
88ca2033f7 Now shared tcb parts freed correctly. 2008-11-09 11:37:24 +02:00
Bahadir Balban
b387a0526a tcb_destroy() in pager and fs0 now caters for shared structures. 2008-11-09 10:40:18 +02:00
Bahadir Balban
63fb907cd0 Made changes to have shared tcb parts in fs0 in preparation for clone()
fs_data and files structures can now be shared in the vfs task.
Currently no means to free shared structures in tcb destruction. Need to add that.
2008-11-09 10:07:24 +02:00
Bahadir Balban
5468c1833d Utcbs of exiting children are successfully unmapped from vfs via sys_shmdt
The shared memory addresses are returned back to their pools via the
deletion function of such objects. They don't get released via do_munmap().
2008-11-08 13:19:15 +02:00
Bahadir Balban
94daebd0c5 Mapping precision fixes on l4_unmap and do_munmap()
l4_unmap now returns -1 if given range was only partially unmapped.

do_munmap() now only unmaps address ranges that have correspondence in
the unmapped vmas. Trying to unmap regions with no correspondent vmas
causes problems in corner cases, e.g. mm0 that tries to mmap its own
address space during initialisation would unmap its whole address space
and fail to execute.
2008-11-08 10:18:35 +02:00
Bahadir Balban
0e3f069713 Removed an overly restrictive BUG_ON assert from scheduler code.
sched_resume_async() used to forbit current tasks to wake up themselves
since it seems tasks can never be runnable to wake themselves up. However
there's a special case in the scheduler where a task that is about to sleep
may notice it has a pending event and wake itself up asynchronously. Since
all sleeping preparation has already been done and scheduler code is a safe
zone, it is safe to undo it all and resume about-to-sleep task in the scheduler.

We may want to put a BKPT in the pager's suspend routine if it waits for the
sleeping task to resume itself, to see if such a wait is successful. It rarely happens.
2008-11-07 21:25:36 +02:00
Bahadir Balban
99b7cf2274 for sys_mmap(), added unmapping of existing vmas for the area that is soon to be mmap'ed. 2008-11-07 21:22:50 +02:00
Bahadir Balban
daffc1d084 Split vmas had no objects. Now fixed.
When sys_munmap() splits a vma, the new vma had no copy of the objects
in the original vma. Now we fixed that using a vma_copy_links() function
which can also be used as part of fork().
2008-11-07 20:39:11 +02:00
Bahadir Balban
61751a896b vma_intersect() was erroneous, replaced by a nice and simple set_intersection() routine.
Still testing sys_munmap(). It now correctly spots and unmaps the overlapping vma.
The issue now is that if a split occurs, we forgot to add same objects to new vma.
2008-11-07 20:13:28 +02:00
Bahadir Balban
93ca3f88a8 Forgot to increase file open count when forking a task. Now fixed.
Also now a file can only be deleted if both open count and map count is zero.
2008-11-07 17:20:11 +02:00
Bahadir Balban
122214f9b5 Increased memfs fixed maximum file size to 40 blocks (i.e. 40 pages) 2008-11-07 16:29:24 +02:00
Bahadir Balban
1ddd7ac9c2 Removed vm_object printfs that were for testing exit().
File open was failing when using 2 files with same name. TODO: Look at it in the future.
Need to increase writeable file size in fs0. 16 pages don't work.
2008-11-07 16:26:07 +02:00
Bahadir Balban
40ccc642f9 Removed find_vma_byrange completely. It was buggy and useless. 2008-11-07 16:12:44 +02:00
Bahadir Balban
f87f3cd5d2 Fixed libposix munmap call where we used the MMAP tag. 2008-11-07 15:18:43 +02:00
Bahadir Balban
f0348cc356 Fixed an msync() issue.
msync used find_vma_byrange() instead of traversing each vma. Fixed now.
2008-11-07 15:10:19 +02:00
Bahadir Balban
3cb36b632a Fixed various bugs in user buffer validation/mapping and mmap() syscall path. 2008-11-07 12:32:10 +02:00
Bahadir Balban
ca8959eee0 Added new routines that map and check the validity of user buffers.
mmap uses this mechanism to get arguments. It needs to be tested.
2008-11-03 11:27:10 +02:00
Bahadir Balban
87d1b91743 Added setting page owner to VM_DIRTY in write_cache_pages. 2008-10-30 11:11:21 +02:00
Bahadir Balban
a2d2574eac Added VM_DIRTY flag for file-backed objects and their pages.
Now file flushing in both munmap() and fsync() caters for VM_DIRTY.
Also write_cache_pages() and write faults set this bit on pages and their objects.
2008-10-30 11:09:15 +02:00
Bahadir Balban
13b1b405a5 Cleaned up libposix mmap()
Now we have proper setting of errno and using pfn based mmap for both types of mmap calls.
2008-10-29 20:01:31 +02:00
Bahadir Balban
4046ad9e3f Added msync(), added handling of munmap/msync to pager main.c 2008-10-29 19:22:01 +02:00
Bahadir Balban
51af9968c2 Added flushing of file pages to do_munmap() for file-backed mappings. 2008-10-29 19:03:19 +02:00
Bahadir Balban
94a126dcde munmap compiling.
do_munmap currently shrinks, splits, destroys vmas and unmaps the given
virtual address range from the task. Unmapped pages may go completely unused
but page reclamation will be done in another part of the pager rather than
directly on the munmap instance.
2008-10-29 16:59:06 +02:00
Bahadir Balban
3421a29693 Few undecided changes on munmap.c 2008-10-29 14:02:21 +02:00
Bahadir Balban
d5b5560bfa Moved munmap functions to munmap.c yet to be modified. 2008-10-27 15:07:06 +02:00
Bahadir Balban
e8c1f31cee Minor cleanups to vm_area.h 2008-10-25 14:32:34 +03:00
Bahadir Balban
12c5389e85 Added counting of different file types to vm integrity tests. 2008-10-25 12:50:31 +03:00
Bahadir Balban
cb9b02a24e Fixed 2 bugs in vma_merge_object().
Looks like it had never been called before.
2008-10-25 12:05:26 +03:00
Bahadir Balban
d43a98b4af Cleaner allocation, mapping and prefaulting of utcb shm segments.
A function has been defined that handles all utcb operations.
2008-10-24 17:20:42 +03:00
Bahadir Balban
46fcdc9b31 Added same global task management mechanism from mm0 to fs0 2008-10-24 14:59:25 +03:00
Bahadir Balban
e875344149 Remove unused functions 2008-10-24 13:55:51 +03:00
Bahadir Balban
651901d8b9 Bugfixes, enhancements
- Fixed an important bug with shadow object handling.
  When a shadow is dropped, if there are references left
  to it, both the object in front and dropped object becomes
  a shadow of the original object underneath. We had thought
  of this case but had not increase the shadow count.

- Added a test mechanism that tests the number of objects,
  vmfiles, shadows etc. by first counting them and trying to
  reach the same number by other means, i.e. per-object-shadow counts.
  It discovered a plethora of bugs.

- Added new set of functions to register objects, files and tasks
  globally with the pager, these functions introduce a refcount as
  well as adding structures to linked lists.

- fork/exit now seems to work stably i.e. no negative shadow counts etc.
2008-10-24 13:45:39 +03:00
Bahadir Balban
b3693de21b Removed unnecessary comments 2008-10-22 21:15:53 +03:00
Bahadir Balban
616b30cdbf Changed the way vm_object_print() was defined.
Now it is switched off or on by comments rather than a single #define
2008-10-22 19:53:03 +03:00
Bahadir Balban
ec863f5521 Removed exit printfs from mm0 and fs0 2008-10-22 16:46:22 +03:00
Bahadir Balban
299549ec4a Added the forgotten freeing of shm id when destroying shm area. 2008-10-22 15:39:18 +03:00
Bahadir Balban
1ee5cc9c2b Fixed a task suspend/resume scheduler issue.
- Scheduler was increasing total priorities only when resuming tasks had 0 ticks.
This caused forked tasks that have parent's share of ticks to finish their jobs,
if these tasks exited quick enough, they would cause the total priorities to deduce
without increasing it in the first place. This is now fixed.

- Also strengthened rq locking, now both queues are locked before touching any.
- Also removed task suspends in irq, this would cause a race condition on ticks and
  runqueues, since neither is protected against irqs.
2008-10-22 13:00:28 +03:00
Bahadir Balban
b20fda9341 exit() seems to work, but needs more testing.
- Added cleaner allocation of shm addresses by moving the allocation to do_mmap().
- Added deletion routine for all objects: shadow, vm_file of type vfs_file, shm_file, etc.
  - Need to make sure objects get deleted properly after exit().
- Currently we allow a single, unique virtual address for each shm segment.
2008-10-21 14:17:58 +03:00
Bahadir Balban
aa2be891cd exit() almost there.
- Implemented reasonable way to suspend task.
  - A task that has a pending suspend would be interrupted
    from its sleep via the suspender task.
  - If suspend was raised and right after, task became about to sleep,
    then scheduler wakes it up.
  - If suspend was raised when task was in user mode, then an irq suspends it.
  - Also suspends are checked at the end of a syscall so that if suspend was
    raised because of a syscall from the task, the task is suspended before it
    goes back to user mode.

  - This mechanism is very similar to signals, and it may lead as a base for
    implementing signal handling.

- Implemented common vma dropping for shadow vm object dropping and task exiting.
2008-10-20 12:56:30 +03:00
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
6b11d3cf02 Added exit() call to libposix 2008-09-18 16:28:51 +03:00
Bahadir Balban
2741adb2c1 Readme update 2008-09-18 15:45:25 +03:00
Bahadir Balban
c788297dce README update 2008-09-18 15:40:42 +03:00
Bahadir Balban
995de95e95 README update 2008-09-18 14:04:17 +03:00
Bahadir Balban
6e3d04dad3 getpid() call 2008-09-17 16:55:37 +03:00
Bahadir Balban
7d4d62cd92 Forktest file added. 2008-09-17 16:21:43 +03:00