SlideShare a Scribd company logo
Maths is not everything

Embedded Systems
6 - Operating Systems

Processes
Context Switching
Multitasking
RMR©2012

UML and Processes
Maths is not everything

Operating Systems
Processes

RMR©2012
Why we need it?
The alternative is to use sequential programming techniques
The programmer must construct the system so that it
involves the cyclic execution of a program sequence to handle
the various concurrent activities
This complicates the programmer's already difficult task and
involves him/her in considerations of structures which are
irrelevant to the control of the activities in hand
The resulting programs will be more obscure and inelegant
It makes decomposition of the problem more complex
Parallel execution of the program on more than one
processor will be much more difficult to achieve
Maths is not everything

RMR©2012

3

The placement of code to deal with faults is more
problematic
Why multiple processes?

Processes help us manage timing
complexity:
multiple rates
multimedia
automotive

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

asynchronous input
user interfaces
communication systems
Example: engine control

Tasks:
spark control
crankshaft sensing
fuel/air mixture
oxygen sensor

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

Kalman filter

engine
controller
Life without processes

Code turns into a
mess:

time

A

interruptions of one
task for another

B

spaghetti code

C

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

A
C

A_code();
…
B_code();
…
if (C) C_code();
…
A_code();
…
switch (x) {
case C: C();
case D: D();
...
Process Representation

Coroutines
Fork and Join
Cobegin
Explicit Process Declaration
Maths is not everything

RMR©2012

7
Co-routines

Co-routine 1
ADR r14,co2a
co1a …
ADR r13,co1b
MOV r15,r14
co1b …

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

ADR r13,co1c
MOV r15,r14
co1c ...

Co-routine 2
co2a …
ADR r13,co2b
MOV r15,r13
co2b …
ADR r13,co2c
MOV r15,r13
co2c …
Co-routine methodology

Like subroutine, but caller determines the
return address.

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

Co-routines voluntarily give up control to
other co-routines.
Pattern of control transfers is embedded
in the code.
Processes

A process is a unique execution of a
program.
Several copies of a program may run simultaneously
or at different times.

A process has its own state:
registers;

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

memory.

The operating system manages processes.
Processes and Threads
All operating systems provide processes
Processes execute in their own virtual machine (VM)
to avoid interference from other processes
Recent OSs provide mechanisms for creating threads
within the same virtual machine; threads are
sometimes provided transparently to the OS
Threads have unrestricted access to their VM
The programmer and the language must provide the
protection from interference
Maths is not everything

RMR©2012

11

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
Concurrent Programming Constructs

Allow
The expression of concurrent execution through the
notion of process
Process synchronization
Inter-process communication.

Processes may be:
independent
Maths is not everything

cooperating
competing

RMR©2012

12
Processes and CPUs

Activation record:
copy of process
state.

process 1

Context switch:

Maths is not everything

RMR©2012

process 2

new CPU context goes in.
© 2008 Wayne Wolf

current CPU context goes
out;

...
memory

PC

registers

CPU
Processes in POSIX

Create a process
with fork:
parent process keeps
executing old program;

process a

child process executes
new program.

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

process a

process b
fork()

The fork process creates child:
childid = fork();
if (childid == 0) {

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

/* child operations */
} else {
/* parent operations */
}
execv()

Overlays child code:
childid = fork();
if (childid == 0) {
execv(“mychild”,childargs);

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

perror(“execv”);
exit(1);
}

file with child code
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

RMR©2012

17

S1, S2 etc, execute concurrently
The statement terminates when S1, S2 etc have
terminated
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

RMR©2012

18

end;

Languages that support explicit process declaration may
have explicit or implicit process/task creation
Maths is not everything

Operating Systems
Context Switching

RMR©2012
Context switching

Who controls when the context is
switched?

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

How is the context switched?
Co-operative multitasking

Improvement on co-routines:
hides context switching mechanism;
still relies on processes to give up CPU.

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

Each process allows a context switch at
cswitch() call.
Separate scheduler chooses which
process runs next.
Problems with co-operative multitasking

Programming errors can keep other
processes out:
process never gives up CPU;

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

process waits too long to switch, missing input.
Context switching

Must copy all registers to activation
record, keeping proper return value for
PC.

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

Must copy new activation record into CPU
state.
How does the program that copies the
context keep its own context?
Context switching in ARM

Save old process:

Start new process:

Save all-reg ⟶ PD

STMIA r13,{r0-r14}^
MRS r0,SPSR

get status

STMDB r13,{r0,r15}

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

Save SPR, PC ⟶ PD

ADR r0,NEXTPROC
get
new PD
LDR r13,[r0]
LDMDB r13,{r0,r14}
set status
MSR SPSR,r0
LDMIA r13,{r0-r14}^
get new context
MOVS pc,r14
set new
PC
Maths is not everything

Operating Systems
Multitasking

RMR©2012
Preemptive multitasking

Most powerful form of multitasking:
OS controls when contexts switches;
OS determines what process runs next.

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

interrupt

CPU

timer

Use timer to call OS, switch contexts:
Flow of control with preemption

interrupt

P1

OS

interrupt

P1

OS

P2

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

time
Preemptive context switching

Timer interrupt gives control to OS,
which saves interrupted process’s state in
an activation record.

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

OS chooses next process to run.
OS installs desired activation record as
current CPU state.
Why not use interrupts?

We could change the interrupt vector at
every period, but:
we would need management code anyway;

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

we would have to know the next period’s process at
the start of the current process.
Processes and UML

A process is an active class---independent
thread of control.
processClass1
myAttributes
myOperations()

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

Signals
start
resume
UML signals

Signal: object that is passed between
processes for active communication:

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

acomm: datasignal
Designing with active objects

Can mix normal and active objects:
p1: processClass1
a: rawMsg

Maths is not everything

RMR©2012

© 2008 Wayne Wolf

w: wrapperClass

ahat: fullMsg

master: masterClass

More Related Content

What's hot

Concurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and SynchronizationConcurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and Synchronization
Anas Ebrahim
 
Process synchronization in operating system
Process synchronization in operating systemProcess synchronization in operating system
Process synchronization in operating system
Ruaha Catholic university
 
Chapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationChapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationWayne Jones Jnr
 
Operating systems question bank
Operating systems question bankOperating systems question bank
Operating systems question bank
anuradha raheja
 
Process synchronization
Process synchronizationProcess synchronization
Process synchronization
Saad11233
 
Ch7 Process Synchronization galvin
Ch7 Process Synchronization galvinCh7 Process Synchronization galvin
Ch7 Process Synchronization galvin
Shubham Singh
 
Operating System-Ch6 process synchronization
Operating System-Ch6 process synchronizationOperating System-Ch6 process synchronization
Operating System-Ch6 process synchronization
Syaiful Ahdan
 
Software rejuvenation based fault tolerance
Software rejuvenation based fault toleranceSoftware rejuvenation based fault tolerance
Software rejuvenation based fault tolerance
www.pixelsolutionbd.com
 
Operating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and DeadlocksOperating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and Deadlocks
Mukesh Chinta
 
Components in real time systems
Components in real time systemsComponents in real time systems
Components in real time systemsSaransh Garg
 
Process synchronization
Process synchronizationProcess synchronization
Process synchronization
Syed Hassan Ali
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.
MOHIT DADU
 
Mutual Exclusion using Peterson's Algorithm
Mutual Exclusion using Peterson's AlgorithmMutual Exclusion using Peterson's Algorithm
Mutual Exclusion using Peterson's AlgorithmSouvik Roy
 
Process synchronization(deepa)
Process synchronization(deepa)Process synchronization(deepa)
Process synchronization(deepa)Nagarajan
 
Operating System Process Synchronization
Operating System Process SynchronizationOperating System Process Synchronization
Operating System Process Synchronization
Haziq Naeem
 
New Features in QP5
New Features in QP5New Features in QP5
New Features in QP5
Quantum Leaps, LLC
 
Rgk cluster computing project
Rgk cluster computing projectRgk cluster computing project
Rgk cluster computing project
OstopD
 
Synchronization linux
Synchronization linuxSynchronization linux
Synchronization linuxSusant Sahani
 

What's hot (20)

Concurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and SynchronizationConcurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and Synchronization
 
Process synchronization in operating system
Process synchronization in operating systemProcess synchronization in operating system
Process synchronization in operating system
 
Chapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationChapter 6 - Process Synchronization
Chapter 6 - Process Synchronization
 
Operating systems question bank
Operating systems question bankOperating systems question bank
Operating systems question bank
 
Process synchronization
Process synchronizationProcess synchronization
Process synchronization
 
Ch7 Process Synchronization galvin
Ch7 Process Synchronization galvinCh7 Process Synchronization galvin
Ch7 Process Synchronization galvin
 
Operating System-Ch6 process synchronization
Operating System-Ch6 process synchronizationOperating System-Ch6 process synchronization
Operating System-Ch6 process synchronization
 
Software rejuvenation based fault tolerance
Software rejuvenation based fault toleranceSoftware rejuvenation based fault tolerance
Software rejuvenation based fault tolerance
 
Operating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and DeadlocksOperating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and Deadlocks
 
Components in real time systems
Components in real time systemsComponents in real time systems
Components in real time systems
 
Process synchronization
Process synchronizationProcess synchronization
Process synchronization
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.
 
Mutual Exclusion using Peterson's Algorithm
Mutual Exclusion using Peterson's AlgorithmMutual Exclusion using Peterson's Algorithm
Mutual Exclusion using Peterson's Algorithm
 
Process synchronization(deepa)
Process synchronization(deepa)Process synchronization(deepa)
Process synchronization(deepa)
 
Mutual exclusion and sync
Mutual exclusion and syncMutual exclusion and sync
Mutual exclusion and sync
 
Operating System Process Synchronization
Operating System Process SynchronizationOperating System Process Synchronization
Operating System Process Synchronization
 
Chapter05 new
Chapter05 newChapter05 new
Chapter05 new
 
New Features in QP5
New Features in QP5New Features in QP5
New Features in QP5
 
Rgk cluster computing project
Rgk cluster computing projectRgk cluster computing project
Rgk cluster computing project
 
Synchronization linux
Synchronization linuxSynchronization linux
Synchronization linux
 

Viewers also liked

Compiler linker loader
Compiler linker loaderCompiler linker loader
Compiler linker loader
Rajani Singh
 
SECR'13 Lightweight linux shared libraries profiling
SECR'13 Lightweight linux shared libraries profilingSECR'13 Lightweight linux shared libraries profiling
SECR'13 Lightweight linux shared libraries profilingOSLL
 
Introduction to Computer Softwares
Introduction to Computer SoftwaresIntroduction to Computer Softwares
Introduction to Computer Softwares
Naresh Dubey
 
Loaders ( system programming )
Loaders ( system programming ) Loaders ( system programming )
Loaders ( system programming )
Adarsh Patel
 
Context Switching
Context SwitchingContext Switching
Context Switchingfranksvalli
 
Process' Virtual Address Space in GNU/Linux
Process' Virtual Address Space in GNU/LinuxProcess' Virtual Address Space in GNU/Linux
Process' Virtual Address Space in GNU/LinuxVarun Mahajan
 
M.c.a. (sem ii) operating systems
M.c.a. (sem   ii) operating systemsM.c.a. (sem   ii) operating systems
M.c.a. (sem ii) operating systems
Tushar Rajput
 
Linker and loader upload
Linker and loader   uploadLinker and loader   upload
Linker and loader upload
Bin Yang
 
Loader
LoaderLoader
Loader
nikhilshrama
 
Linkers And Loaders
Linkers And LoadersLinkers And Loaders
Linkers And Loaders
Satpal Parmar
 

Viewers also liked (13)

Compiler linker loader
Compiler linker loaderCompiler linker loader
Compiler linker loader
 
SECR'13 Lightweight linux shared libraries profiling
SECR'13 Lightweight linux shared libraries profilingSECR'13 Lightweight linux shared libraries profiling
SECR'13 Lightweight linux shared libraries profiling
 
Introduction to Computer Softwares
Introduction to Computer SoftwaresIntroduction to Computer Softwares
Introduction to Computer Softwares
 
Loaders ( system programming )
Loaders ( system programming ) Loaders ( system programming )
Loaders ( system programming )
 
Context Switching
Context SwitchingContext Switching
Context Switching
 
Process' Virtual Address Space in GNU/Linux
Process' Virtual Address Space in GNU/LinuxProcess' Virtual Address Space in GNU/Linux
Process' Virtual Address Space in GNU/Linux
 
AR model
AR modelAR model
AR model
 
Loaders
LoadersLoaders
Loaders
 
M.c.a. (sem ii) operating systems
M.c.a. (sem   ii) operating systemsM.c.a. (sem   ii) operating systems
M.c.a. (sem ii) operating systems
 
Linker and loader upload
Linker and loader   uploadLinker and loader   upload
Linker and loader upload
 
Loader
LoaderLoader
Loader
 
Linkers And Loaders
Linkers And LoadersLinkers And Loaders
Linkers And Loaders
 
Linkers
LinkersLinkers
Linkers
 

Similar to S emb t11-processes

When Web Services Go Bad
When Web Services Go BadWhen Web Services Go Bad
When Web Services Go Bad
Steve Loughran
 
Power-Efficient Programming Using Qualcomm Multicore Asynchronous Runtime Env...
Power-Efficient Programming Using Qualcomm Multicore Asynchronous Runtime Env...Power-Efficient Programming Using Qualcomm Multicore Asynchronous Runtime Env...
Power-Efficient Programming Using Qualcomm Multicore Asynchronous Runtime Env...
Qualcomm Developer Network
 
Performance testing by optimus information inc
Performance testing by optimus information incPerformance testing by optimus information inc
Performance testing by optimus information incOptimus Information Inc.
 
S emb t10-development
S emb t10-developmentS emb t10-development
S emb t10-developmentJoão Moreira
 
Taming startup dynamics - Magnus Jungsbluth & Domagoj Cosic
Taming startup dynamics - Magnus Jungsbluth & Domagoj CosicTaming startup dynamics - Magnus Jungsbluth & Domagoj Cosic
Taming startup dynamics - Magnus Jungsbluth & Domagoj Cosic
mfrancis
 
DDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkDDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFramework
banq jdon
 
Deadline Miss Detection with SCHED_DEADLINE
Deadline Miss Detection with SCHED_DEADLINEDeadline Miss Detection with SCHED_DEADLINE
Deadline Miss Detection with SCHED_DEADLINE
Yoshitake Kobayashi
 
Rtos by shibu
Rtos by shibuRtos by shibu
Rtos by shibu
Shibu Krishnan
 
Prometheus for Monitoring Metrics (Fermilab 2018)
Prometheus for Monitoring Metrics (Fermilab 2018)Prometheus for Monitoring Metrics (Fermilab 2018)
Prometheus for Monitoring Metrics (Fermilab 2018)
Brian Brazil
 
3 processes
3 processes3 processes
3 processes
BaliThorat1
 
rtosbyshibu-131026100746-phpapp01.pdf
rtosbyshibu-131026100746-phpapp01.pdfrtosbyshibu-131026100746-phpapp01.pdf
rtosbyshibu-131026100746-phpapp01.pdf
reemasajin1
 
PPT of PLC and SCADA
PPT of PLC and SCADAPPT of PLC and SCADA
PPT of PLC and SCADA
Mohseen1234
 
Transcend Automation's Kepware OPC Products
Transcend Automation's Kepware OPC ProductsTranscend Automation's Kepware OPC Products
Transcend Automation's Kepware OPC Products
Baiju P.S.
 
How to Configure the CA Workload Automation System Agent agentparm.txt File
How to Configure the CA Workload Automation System Agent agentparm.txt FileHow to Configure the CA Workload Automation System Agent agentparm.txt File
How to Configure the CA Workload Automation System Agent agentparm.txt File
CA Technologies
 
Chapter 3: Processes
Chapter 3: ProcessesChapter 3: Processes
Chapter 3: Processes
Shafaan Khaliq Bhatti
 
Container Orchestration from Theory to Practice
Container Orchestration from Theory to PracticeContainer Orchestration from Theory to Practice
Container Orchestration from Theory to Practice
Docker, Inc.
 
Smpant Transact09
Smpant Transact09Smpant Transact09
Smpant Transact09
smpant
 

Similar to S emb t11-processes (20)

S emb t12-os
S emb t12-osS emb t12-os
S emb t12-os
 
When Web Services Go Bad
When Web Services Go BadWhen Web Services Go Bad
When Web Services Go Bad
 
Power-Efficient Programming Using Qualcomm Multicore Asynchronous Runtime Env...
Power-Efficient Programming Using Qualcomm Multicore Asynchronous Runtime Env...Power-Efficient Programming Using Qualcomm Multicore Asynchronous Runtime Env...
Power-Efficient Programming Using Qualcomm Multicore Asynchronous Runtime Env...
 
Performance testing by optimus information inc
Performance testing by optimus information incPerformance testing by optimus information inc
Performance testing by optimus information inc
 
S emb t10-development
S emb t10-developmentS emb t10-development
S emb t10-development
 
Taming startup dynamics - Magnus Jungsbluth & Domagoj Cosic
Taming startup dynamics - Magnus Jungsbluth & Domagoj CosicTaming startup dynamics - Magnus Jungsbluth & Domagoj Cosic
Taming startup dynamics - Magnus Jungsbluth & Domagoj Cosic
 
S emb t13-freertos
S emb t13-freertosS emb t13-freertos
S emb t13-freertos
 
DDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkDDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFramework
 
Deadline Miss Detection with SCHED_DEADLINE
Deadline Miss Detection with SCHED_DEADLINEDeadline Miss Detection with SCHED_DEADLINE
Deadline Miss Detection with SCHED_DEADLINE
 
Rtos by shibu
Rtos by shibuRtos by shibu
Rtos by shibu
 
Prometheus for Monitoring Metrics (Fermilab 2018)
Prometheus for Monitoring Metrics (Fermilab 2018)Prometheus for Monitoring Metrics (Fermilab 2018)
Prometheus for Monitoring Metrics (Fermilab 2018)
 
3 processes
3 processes3 processes
3 processes
 
rtosbyshibu-131026100746-phpapp01.pdf
rtosbyshibu-131026100746-phpapp01.pdfrtosbyshibu-131026100746-phpapp01.pdf
rtosbyshibu-131026100746-phpapp01.pdf
 
PPT of PLC and SCADA
PPT of PLC and SCADAPPT of PLC and SCADA
PPT of PLC and SCADA
 
Transcend Automation's Kepware OPC Products
Transcend Automation's Kepware OPC ProductsTranscend Automation's Kepware OPC Products
Transcend Automation's Kepware OPC Products
 
How to Configure the CA Workload Automation System Agent agentparm.txt File
How to Configure the CA Workload Automation System Agent agentparm.txt FileHow to Configure the CA Workload Automation System Agent agentparm.txt File
How to Configure the CA Workload Automation System Agent agentparm.txt File
 
Chapter 3: Processes
Chapter 3: ProcessesChapter 3: Processes
Chapter 3: Processes
 
Container Orchestration from Theory to Practice
Container Orchestration from Theory to PracticeContainer Orchestration from Theory to Practice
Container Orchestration from Theory to Practice
 
.net Framework
.net Framework.net Framework
.net Framework
 
Smpant Transact09
Smpant Transact09Smpant Transact09
Smpant Transact09
 

More from João Moreira

Bolt mld1717 11100975
Bolt mld1717 11100975Bolt mld1717 11100975
Bolt mld1717 11100975
João Moreira
 
S emb t9-arch_power (1)
S emb t9-arch_power (1)S emb t9-arch_power (1)
S emb t9-arch_power (1)João Moreira
 
S emb t1-introduction
S emb t1-introductionS emb t1-introduction
S emb t1-introductionJoão Moreira
 

More from João Moreira (10)

Bolt mld1717 11100975
Bolt mld1717 11100975Bolt mld1717 11100975
Bolt mld1717 11100975
 
S emb t9-arch_power (1)
S emb t9-arch_power (1)S emb t9-arch_power (1)
S emb t9-arch_power (1)
 
S emb t9-arch_power
S emb t9-arch_powerS emb t9-arch_power
S emb t9-arch_power
 
S emb t8-arch_itfio
S emb t8-arch_itfioS emb t8-arch_itfio
S emb t8-arch_itfio
 
S emb t7-arch_bus
S emb t7-arch_busS emb t7-arch_bus
S emb t7-arch_bus
 
S emb t6-arch_mem
S emb t6-arch_memS emb t6-arch_mem
S emb t6-arch_mem
 
S emb t5-arch_io
S emb t5-arch_ioS emb t5-arch_io
S emb t5-arch_io
 
S emb t4-arch_cpu
S emb t4-arch_cpuS emb t4-arch_cpu
S emb t4-arch_cpu
 
S emb t2-definition
S emb t2-definitionS emb t2-definition
S emb t2-definition
 
S emb t1-introduction
S emb t1-introductionS emb t1-introduction
S emb t1-introduction
 

Recently uploaded

Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 

Recently uploaded (20)

Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 

S emb t11-processes

  • 1. Maths is not everything Embedded Systems 6 - Operating Systems Processes Context Switching Multitasking RMR©2012 UML and Processes
  • 2. Maths is not everything Operating Systems Processes RMR©2012
  • 3. Why we need it? The alternative is to use sequential programming techniques The programmer must construct the system so that it involves the cyclic execution of a program sequence to handle the various concurrent activities This complicates the programmer's already difficult task and involves him/her in considerations of structures which are irrelevant to the control of the activities in hand The resulting programs will be more obscure and inelegant It makes decomposition of the problem more complex Parallel execution of the program on more than one processor will be much more difficult to achieve Maths is not everything RMR©2012 3 The placement of code to deal with faults is more problematic
  • 4. Why multiple processes? Processes help us manage timing complexity: multiple rates multimedia automotive Maths is not everything RMR©2012 © 2008 Wayne Wolf asynchronous input user interfaces communication systems
  • 5. Example: engine control Tasks: spark control crankshaft sensing fuel/air mixture oxygen sensor Maths is not everything RMR©2012 © 2008 Wayne Wolf Kalman filter engine controller
  • 6. Life without processes Code turns into a mess: time A interruptions of one task for another B spaghetti code C Maths is not everything RMR©2012 © 2008 Wayne Wolf A C A_code(); … B_code(); … if (C) C_code(); … A_code(); … switch (x) { case C: C(); case D: D(); ...
  • 7. Process Representation Coroutines Fork and Join Cobegin Explicit Process Declaration Maths is not everything RMR©2012 7
  • 8. Co-routines Co-routine 1 ADR r14,co2a co1a … ADR r13,co1b MOV r15,r14 co1b … Maths is not everything RMR©2012 © 2008 Wayne Wolf ADR r13,co1c MOV r15,r14 co1c ... Co-routine 2 co2a … ADR r13,co2b MOV r15,r13 co2b … ADR r13,co2c MOV r15,r13 co2c …
  • 9. Co-routine methodology Like subroutine, but caller determines the return address. Maths is not everything RMR©2012 © 2008 Wayne Wolf Co-routines voluntarily give up control to other co-routines. Pattern of control transfers is embedded in the code.
  • 10. Processes A process is a unique execution of a program. Several copies of a program may run simultaneously or at different times. A process has its own state: registers; Maths is not everything RMR©2012 © 2008 Wayne Wolf memory. The operating system manages processes.
  • 11. Processes and Threads All operating systems provide processes Processes execute in their own virtual machine (VM) to avoid interference from other processes Recent OSs provide mechanisms for creating threads within the same virtual machine; threads are sometimes provided transparently to the OS Threads have unrestricted access to their VM The programmer and the language must provide the protection from interference Maths is not everything RMR©2012 11 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
  • 12. Concurrent Programming Constructs Allow The expression of concurrent execution through the notion of process Process synchronization Inter-process communication. Processes may be: independent Maths is not everything cooperating competing RMR©2012 12
  • 13. Processes and CPUs Activation record: copy of process state. process 1 Context switch: Maths is not everything RMR©2012 process 2 new CPU context goes in. © 2008 Wayne Wolf current CPU context goes out; ... memory PC registers CPU
  • 14. Processes in POSIX Create a process with fork: parent process keeps executing old program; process a child process executes new program. Maths is not everything RMR©2012 © 2008 Wayne Wolf process a process b
  • 15. fork() The fork process creates child: childid = fork(); if (childid == 0) { Maths is not everything RMR©2012 © 2008 Wayne Wolf /* child operations */ } else { /* parent operations */ }
  • 16. execv() Overlays child code: childid = fork(); if (childid == 0) { execv(“mychild”,childargs); Maths is not everything RMR©2012 © 2008 Wayne Wolf perror(“execv”); exit(1); } file with child code
  • 17. 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 RMR©2012 17 S1, S2 etc, execute concurrently The statement terminates when S1, S2 etc have terminated
  • 18. 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 RMR©2012 18 end; Languages that support explicit process declaration may have explicit or implicit process/task creation
  • 19. Maths is not everything Operating Systems Context Switching RMR©2012
  • 20. Context switching Who controls when the context is switched? Maths is not everything RMR©2012 © 2008 Wayne Wolf How is the context switched?
  • 21. Co-operative multitasking Improvement on co-routines: hides context switching mechanism; still relies on processes to give up CPU. Maths is not everything RMR©2012 © 2008 Wayne Wolf Each process allows a context switch at cswitch() call. Separate scheduler chooses which process runs next.
  • 22. Problems with co-operative multitasking Programming errors can keep other processes out: process never gives up CPU; Maths is not everything RMR©2012 © 2008 Wayne Wolf process waits too long to switch, missing input.
  • 23. Context switching Must copy all registers to activation record, keeping proper return value for PC. Maths is not everything RMR©2012 © 2008 Wayne Wolf Must copy new activation record into CPU state. How does the program that copies the context keep its own context?
  • 24. Context switching in ARM Save old process: Start new process: Save all-reg ⟶ PD STMIA r13,{r0-r14}^ MRS r0,SPSR get status STMDB r13,{r0,r15} Maths is not everything RMR©2012 © 2008 Wayne Wolf Save SPR, PC ⟶ PD ADR r0,NEXTPROC get new PD LDR r13,[r0] LDMDB r13,{r0,r14} set status MSR SPSR,r0 LDMIA r13,{r0-r14}^ get new context MOVS pc,r14 set new PC
  • 25. Maths is not everything Operating Systems Multitasking RMR©2012
  • 26. Preemptive multitasking Most powerful form of multitasking: OS controls when contexts switches; OS determines what process runs next. Maths is not everything RMR©2012 © 2008 Wayne Wolf interrupt CPU timer Use timer to call OS, switch contexts:
  • 27. Flow of control with preemption interrupt P1 OS interrupt P1 OS P2 Maths is not everything RMR©2012 © 2008 Wayne Wolf time
  • 28. Preemptive context switching Timer interrupt gives control to OS, which saves interrupted process’s state in an activation record. Maths is not everything RMR©2012 © 2008 Wayne Wolf OS chooses next process to run. OS installs desired activation record as current CPU state.
  • 29. Why not use interrupts? We could change the interrupt vector at every period, but: we would need management code anyway; Maths is not everything RMR©2012 © 2008 Wayne Wolf we would have to know the next period’s process at the start of the current process.
  • 30. Processes and UML A process is an active class---independent thread of control. processClass1 myAttributes myOperations() Maths is not everything RMR©2012 © 2008 Wayne Wolf Signals start resume
  • 31. UML signals Signal: object that is passed between processes for active communication: Maths is not everything RMR©2012 © 2008 Wayne Wolf acomm: datasignal
  • 32. Designing with active objects Can mix normal and active objects: p1: processClass1 a: rawMsg Maths is not everything RMR©2012 © 2008 Wayne Wolf w: wrapperClass ahat: fullMsg master: masterClass