Commit Graph

721 Commits

Author SHA1 Message Date
Bahadir Balban
5992b6435c Added a forgotten unlock on an error condition 2009-11-01 15:22:36 +02:00
Bahadir Balban
83a740f597 A better locking scheme for address spaces.
Same shall be done for the tcb list.
2009-11-01 14:32:55 +02:00
Bahadir Balban
003976e99e Comment formatting 2009-11-01 01:36:03 +02:00
Bahadir Balban
5fd0f12017 Added handling of task pending events from scheduler.
Previously all pending events were handled on return of exceptions
in process context. This was causing threads that run in userspace
and take no exceptions not handle their pending events indefinitely.
Now scheduler handles them in irq context as well.
2009-11-01 01:03:17 +02:00
Bahadir Balban
0f537ea1f5 Wait on working.
Multi-threaded apps can now wait on children to destroy.
WAIT_ON is useful when a child exists with an exit code and the pager
of the child does not want to take the hassle of destorying it via an
ipc. It provides an alternative method of synchronous thread destruction,
where the child destroys itself directly rather than the parent issuing
a destroy on it explicitly.
2009-10-31 23:28:54 +02:00
Bahadir Balban
850c645d77 Exiting tasks use EXITING signal and change states to TASK_DEAD 2009-10-31 23:13:19 +02:00
Bahadir Balban
5ed93b6563 Thread exiting
Pagers kill all children but suspend themselves.
Currently not straightforward for a pager to delete its own tcb and quit.
It should take all allocator locks without sleeping, remove itself from
scheduler queue and then delete itself and quit. This is not so easy now
as some allocation locks are mutexes. (Address space lock, ktcb/space
allocators etc.)

An easier approach would be to have a kernel thread or a superior thread
that would delete the pager
2009-10-31 22:46:29 +02:00
Bahadir Balban
c763679aaa Fixed a nasty spinlock issue with wake_up_all that didn't get caught. 2009-10-31 20:47:20 +02:00
Bahadir Balban
638df9e238 Simultaneous exit/thread_destroy working
Reiterating again to simplify:

Working:
 - Pager issues destroy, client also issues exit
   they work in sync.

Missing
 - Pager killing itself
 - Pager killing all children while killing itself
 - Pager waiting on children
2009-10-31 18:45:22 +02:00
Bahadir Balban
09197d1fb1 Removed THREAD_WAIT call completely.
Simply reverse this patch to add THREAD_WAIT
2009-10-31 17:12:03 +02:00
Bahadir Balban
dd5e05380c Typo fix 2009-10-31 16:39:13 +02:00
Bahadir Balban
53589ada01 Amendments to scheduler timeslice management 2009-10-31 15:25:29 +02:00
Bora Sahin
2571dabc18 Fixes to the scheduler timeslice management.
One is related to the time distribution when a new child is created.
If the parent has one tick left, then both child and parent received
zero tick. When combined with
	current_irq_nest_count = 1
	voluntary_preempt = 0
values, this caused the scheduler from being invoked.

Second is related to the overall time distribution. When a thread
runs out of time, its new time slice is calculated by the below
formula:
	new_timeslice = (thread_prio * SCHED_TICKS) / total_prio
If we consider total_prio is equal to the sum of the priorities of
all the threads in the system, it imposes a problem of getting
zero tick. In the new scenario, total_prio is equal to the priority
types in the system so it is fixed. Every thread gets a timeslice
in proportion of their priorities. Thus, there is no risk of taking
zero tick.
2009-10-31 15:08:53 +02:00
Bora Sahin
90cfaca7a2 libmem/lib{mm,mc,malloc} are added to the libraries of bare containers
againist which they are linked.
(cherry picked from commit 9d90ee4c57f07dbbe984251023fc3fa684dd492c)
2009-10-31 14:31:32 +02:00
Bora Sahin
38cf7bc175 POSIX now uses libmem/malloc instead of the built-in one.
(cherry picked from commit 48adbffa6514755385af842f1fe8ca5068229eea)
2009-10-31 14:31:13 +02:00
Bora Sahin
2c53feedb1 malloc is carried from POSIX to libmem/malloc.
This malloc is a very simple first-fit sort of allocator. Now, it builds
without any problem but because we havent fixed include paths and added
it to the referenced libraries in the posix container yet, POSIX doesnt
build. So take it with caution.
(cherry picked from commit 65523743e86268eddd3bd2aab58476003f71c2c2)
2009-10-31 14:28:40 +02:00
Bahadir Balban
5c93d9b8ba Added thread_wait
modified:   conts/test/main.c
	modified:   scripts/kernel/generate_kernel_cinfo.py
	modified:   src/api/thread.c
	modified:   src/generic/capability.c
2009-10-31 01:44:32 +02:00
Bahadir Balban
2839f46245 Cleanup on previous commits 2009-10-30 21:59:46 +02:00
Bahadir Balban
c3c6c10cf7 Reimplemented kill/suspend
It seems to work fine except an undefined instruction is generated
from posix userspace occasionally
2009-10-30 21:34:10 +02:00
Bahadir Balban
f3c0a38fa9 Some not-very-well working progress on grouply exit.
Going to start from scratch.
2009-10-30 19:52:52 +02:00
Bahadir Balban
ee7621b2df Some more progress with debugging pager exits 2009-10-30 18:28:45 +02:00
Bahadir Balban
18ffa0b4d1 Added a TASK_CAP_LIST macro that abstracts away the primary cap list
We moved initial list of a pager's caps from ktcb to task's space
since the task is expected to trust its space.

Most references to task->cap_list had to change. Although a single
cap list only tells part of the story about the task's caps, the
TASK_CAP_LIST macro works for us to get the first private set of
caps that a task has.
2009-10-30 13:46:47 +02:00
Bahadir Balban
118fc795d9 Added wakeup call during exit in case pager was trying to suspend us. 2009-10-30 12:45:31 +02:00
Bahadir Balban
26aa62d2ea Added different paths of exiting for pager and its children.
Created a task_dead list on pager for children to move to when
they exit.
2009-10-30 12:00:05 +02:00
Bahadir Balban
a6c61e05b9 l4_exit() works with a reasonable sched_die_sync()
Next: Killing other tasks more cleanly, and waiting on children
2009-10-29 22:44:58 +02:00
Bahadir Balban
73a27f2269 Modifications for exit/wait on test container 2009-10-27 20:22:42 +02:00
Bahadir Balban
bc91edba76 Few minor userspace polishes on caps for kernel changes 2009-10-27 18:39:09 +02:00
Bahadir Balban
5840d6d696 Capability-enabled kernel running 2_posix test OK. 2009-10-27 15:59:07 +02:00
Bahadir Balban
d1f25763ac Added a conceptual multithreaded app with no capability enforcement.
It is important to be able to create environments with not much
involvement with capability management. This is to increase usability
of the system and provide the option of having simpler api with
less security-oriented applications.
2009-10-26 14:08:41 +02:00
Bahadir Balban
5ecef40312 Added a conceptual prototype of a capability sharing example. 2009-10-26 13:34:34 +02:00
Bahadir Balban
88e3706474 Capability checking added as compiling code.
Capability checking for thread_control, exregs, mutex, cap_control,
ipc, and map system calls.

The visualised model is implemented in code that compiles, but
actual functionality hasn't been tested.

Need to add:
- Dynamic assignment of initial resources matching with what's
defined in the configuration.
- A paged-thread-group, since that would be a logical group of
seperation from a capability point-of-view.
- Resource ids for various tasks. E.g.
  - Memory capabilities don't have target resources.
  - Thread capability assumes current container for THREAD_CREATE.
  - Mutex syscall assumes current thread (this one may not need
    any changing)
  - cap_control syscall assumes current thread. It may happen to
    be that another thread's capability list is manipulated.

Last but not least:
- A simple and easy-to-use userspace library for dynamic expansion
  of resource domains as new resources are created such as threads.
2009-10-25 23:57:17 +02:00
Bahadir Balban
83ce4280b0 Some capability checking progress 2009-10-24 18:44:47 +03:00
Bahadir Balban
4a24e02151 Reorganized test container sources 2009-10-23 16:41:30 +03:00
Bahadir Balban
6093214981 Added sharing of pager capabilities with children or siblings
Pagers can now share their own private capabilities with their
paged children, or their siblings with whom they have a common pager
ancestor.

Added flags CAP_SHARE_CHILD and CAP_SHARE_SIBLINGS for that.
2009-10-23 13:50:32 +03:00
Bahadir Balban
f4c9ea50bc Added an example test container configuration 2009-10-23 12:32:53 +03:00
Bahadir Balban
8cabfa3e37 Capability sharing test added.
Pagers by default do not share their capabilities with their children.

By using one of CAP_SHARE_SPACE, CAP_SHARE_GROUP or CAP_SHARE_CONTAINER
a pager may now share its capabilities with a collection of threads.
2009-10-23 12:30:30 +03:00
Bora Sahin
4bdbe42850 Linker script is removed from the bare container template.
This is unnecessary because it is autogenerated.
(cherry picked from commit 36e3982b5c769090df00964651f4127ed7c34bd8)
2009-10-23 03:03:57 +03:00
Bora Sahin
2a47e425c4 Test container type is added.
Test container is planned to test codezero microkernel extensively.
With these changes, everything is there to develop a full-featured test suite.
It also exemplifies how a new container type can be added to the system.
(cherry picked from commit f21fa53df421bfc8eeeaa096c89b98beed436c60)
2009-10-23 03:03:14 +03:00
Bahadir Balban
89d49ef495 Lots of fixes, notion of pager hierarchy, fixed tgroup capability checking
Notion of pager hierarchy introduced using the existing but unused
pagerid field.

Thread creation now has two more flags TC_AS_PAGER and TC_SHARE_PAGER.
The former sets creator as pager, the latter sets creator's pager as pager.

Thread group capability sharing now correctly carries shared capabilities
to the thread group leader's tgr_cap_list list, and this list is checked
during capability checking.
2009-10-23 02:36:12 +03:00
Bahadir Balban
df776b568f Tests working up to neverending suspend - Will be fixed. 2009-10-22 22:50:50 +03:00
Bahadir Balban
948dd4fa71 Added quick saving of configuration with -s 2009-10-22 16:14:37 +03:00
Bahadir Balban
4f2954af8a Fixed a minor config issue + updated example cml files. 2009-10-22 15:46:58 +03:00
Bahadir Balban
0f9ea9674c Progress on capabilities
Capabilities will be shared among collection of threads. A pager
will have a right to share its own capabilities with its space,
its thread group and its container.

Currently sharing is possible with only all of the caps. Next,
it will be support for cap splitting, granting, and partial sharing
and granting.
2009-10-22 14:04:25 +03:00
Bahadir Balban
c6bdd65e48 Minor mods on linux patches 2009-10-21 21:27:41 +03:00
Bahadir Balban
4f5ab576b8 Merge branch 'master' into devel 2009-10-21 20:38:18 +03:00
Bahadir Balban
cc2d740900 Neater thread creation flags. 2009-10-21 16:58:10 +03:00
Amit Mahajan
8d38c8ede6 Corrected the PC value for non linux containers. 2009-10-21 17:02:03 +05:30
Amit Mahajan
89a937fc9c Generating LMA for final.elf dynamically 2009-10-21 16:47:56 +05:30
Amit Mahajan
8bb1069553 Adding mechanism to have differnt run and load address for pagers 2009-10-21 16:45:06 +05:30
Amit Mahajan
be9b629836 Corrected the way to find config.h's path 2009-10-21 16:42:32 +05:30