Emb Mod4
Emb Mod4
Module 4
2
EMBEDDEDFIRMWARE&OPERATINGSYSTEMCONCEPTS
General Purpose OS, Embedded OS, Network OS Once intelligence is imparted to Hardware { i.e ROM programmed} end
1
Mod4 Courtesy Prof Lyla B Das
Process Management
Adaptability ensured by leaving some
Memory Management
configuration variables in the Flash RAM
IO Management
Firmware developer need to understand the File Management
Multiprogramming
application desired, components used in
Protection and Security
hardware, memory map and a programming Network Management
language {assembly /C/ Java }
Level 1- less important part of system software Applications have access to Kernal through “System Call” interface
Level2 –software utilities
Types
Level 3 – application pgms
Monolithic kernel – complete Kernal as a single unit – so failure is catastrophic- ex:Solaris
Microkernels - broken into sections and some run in user space –these are called servers.. total
crash avoided.. Only those ’servers’ that fails need be reconfigured– hence robust ex: Mach
2
Mod4 Courtesy Prof Lyla B Das
3
Mod4 Courtesy Prof Lyla B Das
GPOS RTOS
RT is debatable
GPOS is used for designs similar to conventional computing machines –
ex: patient monitoring systems Deterministic behavior is the key
Kernal is general and contains all general services OS must consume only known / expected amount of time regardless of
API (Application Programming interface) is provided as the task PREDICTABLE BEHAVIOR
interface between OS and the applications built on top of OS Time critical applications governed by strict policies to avoid conflicts
API offers functions, routines, protocols needed to simplify the Ex: Windows Embedded compact, VxWorks
END user experience in target code development Basic functions Process management, scheduling, synchronization,
Ex:To use ADC in the system, ADC () function is provided as an Error/Exception handling, Interrupt handling, Time management,
API
Memory management
Ex: Windows Embedded 8.1
4
Mod4 Courtesy Prof Lyla B Das
Some Terms Associated with Operating Systems Some Terms Associated with Operating Systems
18 19
Tasks/Processes
20 21
5
Mod4 Courtesy Prof Lyla B Das
Stack Memory
The five states are named as
New(create), Ready, Running, Blocked and Exit.
Stack Memory grows
downwards
Data memory
Code memory
6
Mod4 Courtesy Prof Lyla B Das
7
Mod4 Courtesy Prof Lyla B Das
Definition Is the single Stack Memory for thread 1 If all subfunctions in a task are executed sequentially,
sequential flow of execution processor utilisation may not be 100%
Stack Memory for thread 2
through the process code
So instead of single sequential execution of task/process, it is
Each thread belongs to exactly 1 : split into different smaller sequential pieces carrying out
process and no thread can exist :
: relatively independent subfunctionalities
outside a process
When one thread enter a wait state another thread can br
Types of thread: Data memory for process
queued up and avoid processor stalling- process becomes
User level threads
Code memory for process faster
Kernel level threads
Disadv: management overhead
Memory Organisation for Threads
8
Mod4 Courtesy Prof Lyla B Das
Features
If one thread is blocked , kernel can schedule another thread of
Is the act of pre empting currently running thread same process
Slower to create and manage
temporarily
Thread management done by kernel
The procedure depends on whether thread is user level or Kernel threads are Supported directly by OS
kernel level Pre-emptive
Kernel performs
Creation
Scheduling
management
User managed threads Implementation is by thread library OS supports creation of kernel threads
Kernel is not aware of the existence of threads
i.e even if there are multiple threads in user task, KERNAL sees it as a
single thread only Generic and run on any OS Specific to the OS
No OS intervention needed for thread switching
Thread library contains code for- Multi-threaded applications cannot Kernel routines themselves can be
Creating,destroying take advantage of multiprocessing.. As multithreaded
Passing message and data between threads KERNAL is ignorant of user thread
Scheduling thread execution existence in general
Saving and restoring thread contexts.
9
Mod4 Courtesy Prof Lyla B Das
Multithreading models ----- Many – to – One Multithreading models ------ One– to – One
41 42
Many user level threads are mapped to single kernel One thread in user to one thread in kernel
thread More concurrency than many- to- one model
Thread management is done by thread library Allows another thread to run when a thread makes
When thread makes a blocking system call, entire blocking system call
process will be blocked. Supports multiple threads to execute in parallel
Only one thread can access kernel at a time, so
multiple threads are unable to run in parallel.
10
Mod4 Courtesy Prof Lyla B Das
Process is a program in execution and Thread is a single unit of execution and part of
contains one or more threads process
Process has it own code memory, data Thread does not have it own code memory, data
memory and stack memory- It shares with other threads of the same
process . But usually maintains a stack of its own
A process contain at least one thread A thread cannot exist independently .. It lives
within process
Process is expensive to create .. Involves Thread is inexpensive to create….in general
OS overhead
Process switching is complex , slow and Thread context switching is fast and relatively
relatively expensive. inexpensive
If a process dies, resources go back to OS If a thread expires, resources are reclaimed by
and all associated threads also die process
11
Mod4 Courtesy Prof Lyla B Das
So NO one task should be allowed monopolize the processor Multitasking is time multiplexing effect at a high rate
Psuedo Parallelism by time sharing – each task gets its time a User is unaware of task switching happening at
chunk of it and then task switching is done to relinquish its claim processor level
over resources User - made to believe – that all tasks are going on
TCB has the task context {information} to help pick up when a in parallel
relinquished task gets its next turn. As number of tasks increase, “system will slowdown”
12
Mod4 Courtesy Prof Lyla B Das
Some aspects
• CPU utilization
• Only one processor and it should not idle
• Response time
• Interval for which a task waits to be taken up for execution by the processor
• Must be minimum
• Turnaround time (TAT)
• Interval between the instant task is presented to the system to the instant it
exits
• TAT = Twait in Ready Queue +T service ( including blocked time)
• Throughput rate
• Number of tasks processed in unit time
• Inverse of TAT
Scheduling
Non Pre-
Pre-emptive
emptive
Pre-emptive
Shortest Job Pre-emptive SJN/Shortest
Co operative Priority Based Round robin
Next SJN Priority Remaining
Time
13
Mod4 Courtesy Prof Lyla B Das
Co-operative Scheduling
Each task is allowed to execute to its finish,
then only the next one is taken up.
While one task executes, the others are willing to
wait and this gives the name ‘co-operative’ to the
scheduling algorithm.
This is also a case of first come first serve scheduling
/ a first in first out scheme (FCFS/FIFO) or last come
first serve scheduling / a last in first out scheme
(LCFS/LIFO)
Dr Binu Paul Dr Binu Paul 56
T1 300
FCFS
T2 125
Solution Shortest Job Next (SJN) /Shortest Job First
T3 400
57 58
T4 150
T5 100
14
Mod4 Courtesy Prof Lyla B Das
T1 300
T2 125
T3 400
T4 150
T5 100
T1 300
T1 300
Solution T2 125
T2 125 T3 400
T3 400 T4 150
T4 150 T5 100
T5 100 T6 250
T6 250 T7 200
T7 200
15
Mod4 Courtesy Prof Lyla B Das
Priority-based Scheduling
63
Solution
T1 300 5
T2 125 3
T3 400 2
T4 150 12
T5 100 15
16
Mod4 Courtesy Prof Lyla B Das
17
Mod4 Courtesy Prof Lyla B Das
T1 150
T2 100
T3 200
T4 50
18
Mod4 Courtesy Prof Lyla B Das
T1 300 5
Solution T2 125 3
T3 400 2
T4 150 12
T5 100 15
T6* 75 1
19
Mod4 Courtesy Prof Lyla B Das
Solution T1 300
T2 125 END of presentation
T3 400
T4 150
T5 100
T6 50
20