2 Process Mgmnt
Transcript of 2 Process Mgmnt
-
8/9/2019 2 Process Mgmnt
1/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.1
REAL TIME OPERATINGREAL TIME OPERATING
SYSTEMSSYSTEMS
LessonLesson--2:2:PROCESS MANAGEMENTPROCESS MANAGEMENT
-
8/9/2019 2 Process Mgmnt
2/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.2
1. Process Creation1. Process Creation
-
8/9/2019 2 Process Mgmnt
3/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.3
Step 1: At the reset of the processor. in aStep 1: At the reset of the processor. in a
computer system, an OS is initialized firstcomputer system, an OS is initialized first
enabling the use of the OS functions, whichenabling the use of the OS functions, which
includes the function to create the processesincludes the function to create the processes
Step 2: Using OS process creation function, aStep 2: Using OS process creation function, a
process, which can be called initial process, isprocess, which can be called initial process, is
created.created.Step 3: OS started and that calls the initialStep 3: OS started and that calls the initial
process to run.process to run.
Process creationProcess creation
-
8/9/2019 2 Process Mgmnt
4/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.4
Process creationProcess creation
Step 4: When the initial process runs, it
creates subsequent processes.
Processes can be created hierarchically.
OS schedules the threads and provide forcontext switching between the threads (or
tasks).
-
8/9/2019 2 Process Mgmnt
5/21
-
8/9/2019 2 Process Mgmnt
6/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.6
(a) Context
(ii) Process stack pointer
(iii) Current state [Is it created, activated or
spawned? Is it running? Is it blocked?] (iv) Addresses that are allocated and that are
presently in use
PCBPCB
-
8/9/2019 2 Process Mgmnt
7/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.7
(v) Pointer for the parent process (vi) Pointer to a list of daughter processes.
(vii) Pointer to a list of resources, which areusable (consumed) only once. Forexamples, input data, memory buffer orpipe, mailbox message, semaphore
(viii) Pointer to a list of resources, which
are usable (consumed) only once
PCBPCB
-
8/9/2019 2 Process Mgmnt
8/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
8
(ix) Pointer to queue of messages.
(x) Pointer to Access-permissions
descriptor
(xi)ID
PCBPCB
-
8/9/2019 2 Process Mgmnt
9/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
9
2. Example of Process Creation2. Example of Process Creation
-
8/9/2019 2 Process Mgmnt
10/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
10
OS function creates a process usingOS_Task_Create ( ) functionTask_Send_Card_Info in the mai
Task_Send_Card_Info task creates twoother tasks, Task_Send_Port_Output andTask_Read_Port_Input.
OS then controls the context switching
between the processes
OS_Task_Create ( ) functionOS_Task_Create ( ) function
-
8/9/2019 2 Process Mgmnt
11/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
11
OS Process Creation functionOS Process Creation function
OS function first creates theDisplay_process.Display_process creates
Display_Time_DateThread
Display_BatteryThread Display_SignalThread
Display_ProfileThread
Display_MessageThread Display_Call StatusThread
Display_MenuThread
-
8/9/2019 2 Process Mgmnt
12/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
12
3. Message passing and System call to3. Message passing and System call to
OS by ProcessesOS by Processes
-
8/9/2019 2 Process Mgmnt
13/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
13
Message Passing by process running inMessage Passing by process running in
user modeuser mode Generates and puts (sends) a message
OS lets the requested resource (for example, input
from a device or from a queue) use or run an OS
service function (for example, define a delayperiod after which process needs to be run again).
A message can be sent for the OS to let the LCD
display be used by a task or thread for sending the
output. An ISR sends a message to a waiting thread to
start on return from the ISR
-
8/9/2019 2 Process Mgmnt
14/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
14
System call by process running in userSystem call by process running in user
modemode Call to a function defined at the OS.
For example, OSTaskCreate ( )to create a task.
First an SWI instruction is issued to trap the
processor and switch to supervisory mode. OS then executes a function like a library function
Processor on finishing the instructions of a called
function, the processor again switches back to user
mode and lets the calling process run further
-
8/9/2019 2 Process Mgmnt
15/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
15
4. Process Manager Functions4. Process Manager Functions
-
8/9/2019 2 Process Mgmnt
16/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
16
(i) makes it feasible to let for a process tosequentially execute or block when needinga resource and to resume when it becomesavailable,
(ii) implements the logical link to theresource manager for resourcesmanagement (including scheduling ofprocess on the CPU),
Process managerProcess manager
-
8/9/2019 2 Process Mgmnt
17/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
17
(iii) allows specific resources sharingbetween specified processes only,
(iiiv) allocates the resources as per the
resource allocation- mechanism of thesystem and
(iv) manages the processes and resources ofthe given system.
Process managerProcess manager
-
8/9/2019 2 Process Mgmnt
18/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
18
SummarySummary
-
8/9/2019 2 Process Mgmnt
19/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
19
We learntWe learnt
Process manager has functions to create theprocesses,
allocates a PCB to each process,
manages access to the resources andfacilitates the switching from one process
state to another.
The PCB defines the process structure for aprocess state.
-
8/9/2019 2 Process Mgmnt
20/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
20
We learntWe learnt
Process can send a message and make asystem call to enable OS actions and run OS
function
-
8/9/2019 2 Process Mgmnt
21/21
2008 Chapter-8 L2: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
21
End of Lesson 2 of Chapter 8End of Lesson 2 of Chapter 8