Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Embedded Systems
6 - Operating Systems
RMR2012
RMR2012
asynchronous input
Maths is not everything
RMR2012
Tasks:
spark control crankshaft sensing fuel/air mixture oxygen sensor Kalman lter
Maths is not everything
engine controller
RMR2012
time
A B C A
RMR2012
A_code(); B_code(); if (C) C_code(); A_code(); switch (x) { case C: C(); case D: D(); ...
Process Representation
RMR2012
Co-routines
Co-routine 2 co2a ADR r13,co2b MOV r15,r13 co2b ADR r13,co2c MOV r15,r13 co2c
RMR2012
Co-routine methodology
Like subroutine, but caller determines the return address. Co-routines voluntarily give up control to other co-routines.
2008 Wayne Wolf
RMR2012
Processes
RMR2012
Long debate over whether language should define concurrency or leave it up to the O.S.
Ada and Java provide concurrency C, C++ do not
RMR2012
11
Allow
The expression of concurrent execution through the notion of process Process synchronization Inter-process communication.
cooperating competing
RMR2012
12
process 1 process 2
PC
registers
...
memory
CPU
RMR2012
Processes in POSIX
process a
process b
RMR2012
fork()
RMR2012
execv()
exit(1); }
RMR2012
Cobegin
The cobegin (or parbegin or par) is a structured way of denoting the concurrent execution of a collection of statements:
cobegin S1; S2; S3; . . Sn coend
Maths is not everything
S1, S2 etc, execute concurrently The statement terminates when S1, S2 etc have terminated
RMR2012
17
Explicit Process Declaration The structure of a program can be made clearer if routines state whether they will be executed concurrently Note that this does not say when they will execute
task body Process is begin . . .
Maths is not everything
end;
RMR2012
Languages that support explicit process declaration may have explicit or implicit process/task creation
18
RMR2012
Context switching
Who controls when the context is switched? How is the context switched?
RMR2012
Co-operative multitasking
Improvement on co-routines:
hides context switching mechanism; still relies on processes to give up CPU.
RMR2012
RMR2012
Context switching
Must copy all registers to activation record, keeping proper return value for PC. Must copy new activation record into CPU state.
Maths is not everything
RMR2012
How does the program that copies the context keep its own context?
STMDB r13,{r0,r15}
RMR2012
RMR2012
Preemptive multitasking
RMR2012
interrupt
interrupt
P1
OS
P1
OS
P2
time
Maths is not everything
RMR2012
Timer interrupt gives control to OS, which saves interrupted processs state in an activation record. OS chooses next process to run.
2008 Wayne Wolf
RMR2012
RMR2012
RMR2012
start resume
UML signals
RMR2012
w: wrapperClass
2008 Wayne Wolf
ahat: fullMsg
master: masterClass
RMR2012