| | 1 | = MutekS = |
| | 2 | |
| | 3 | MutekS is the canonical Operating System for embedded software. |
| | 4 | It only implements the few system calls used by DSX. |
| | 5 | |
| | 6 | [source:trunk/dsx/lib/muteks] |
| | 7 | |
| | 8 | == Available services == |
| | 9 | |
| | 10 | * Locks (spin locks) |
| | 11 | * Synchronization barriers |
| | 12 | * Mwmr fifos |
| | 13 | |
| | 14 | == Implementation notes == |
| | 15 | |
| | 16 | Scheduler is very basic. It's build on the simple assertion scheduling decisions can be simplified to comparing a address value vith a fixed value. |
| | 17 | Six calls are available to set a thread waiting: |
| | 18 | {{{ |
| | 19 | sched_wait_eq |
| | 20 | sched_wait_ne |
| | 21 | sched_wait_gt |
| | 22 | sched_wait_lt |
| | 23 | sched_wait_ge |
| | 24 | sched_wait_lt |
| | 25 | }}} |
| | 26 | |
| | 27 | Thus locking becomes: |
| | 28 | {{{ |
| | 29 | /* |
| | 30 | * Waits until a 0 is read at the lock address. This is only true when you get the lock |
| | 31 | */ |
| | 32 | sched_wait_eq( &lock, 0 ); |
| | 33 | }}} |
| | 34 | |
| | 35 | Waiting on mwmr becomes: |
| | 36 | {{{ |
| | 37 | /* |
| | 38 | * Read on fifo, need data in it |
| | 39 | * Wait on status before getting the lock, we are read-only and we'll refresh the value once the lock gotten |
| | 40 | */ |
| | 41 | ... |
| | 42 | try_again: |
| | 43 | sched_wait_ge( &(mwmr->status), needed ); |
| | 44 | dsx_lock_lock( mwmr->lock ); |
| | 45 | if ( mwmr->status < needed ) { |
| | 46 | // Someone probably got the lock in between and emptied the fifo |
| | 47 | dsx_lock_unlock( mwmr->lock, needed ); |
| | 48 | goto try_again; |
| | 49 | } |
| | 50 | ... |
| | 51 | }}} |
| | 52 | |
| | 53 | And so on... |