Chap 7Lesson01EmsysNewProcess

download Chap 7Lesson01EmsysNewProcess

of 26

Transcript of Chap 7Lesson01EmsysNewProcess

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    1/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    1

    Inter-Process Communication and

    Synchronization of Processes,

    Threads and Tasks:

    Lesson-1: PROCESS

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    2/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    2

    Process ConceptsProcess Concepts

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    3/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    3

    ProcessProcess A process consists of executable

     program (codes),state

    of which iscontrolled by OS,

    The state during running of a process ! 

    represented by process-status (running, blocked, or finished), process-structure—its data, objects andresources, and process control block(PCB).

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    4/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    4

    • Runs when it is scheduled to run by the

    OS (kernel)• OS gives the control of the CPU on a

     process’s request (system call).

    • Runs by executing the instructions and

    the continuous changes of its state takes

     place as the program counter (PC)changes

    Process….Process….

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    5/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    5

    • Process is that executing unit of

    computation, which is controlled by some process (of the OS) for a scheduling

    mechanism that lets it execute on the CPU

    and by some process at OS for a resource-management mechanism that lets it use

    the system-memory and other system-resources such as network, file, display or

     printer 

    Process …Process …

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    6/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    6

    Application program can be said toApplication program can be said to

    consist of number of processesconsist of number of processes

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    7/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    7

    Example ! Mobile Phone Device

    embedded software

    Software highly complex.

     Number of functions, ISRs, processes

    threads, multiple physical and virtual

    device drivers, and several programobjects that must be concurrently

     processed on a single processor.

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    8/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    8

    Voice encoding and convoluting process ! the device captures the

    spoken words through a speaker andgenerates the digital signals afteranalog to digital conversion, the digitsare encoded and convoluted using aCODEC,

    Modulating process, Display process,

    Exemplary processes at the phone deviceExemplary processes at the phone device

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    9/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    9

    GUIs (graphic user interfaces), and

    Key input process ! 

    for provisioningof the user interrupts

    Exemplary processes at the phone deviceExemplary processes at the phone device

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    10/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    10

    ProcessProcess

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    11/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    11

    Process Control Block Process Control Block 

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    12/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    12

    Process Control BlockProcess Control Block

    A data structure having the information

    using which the OS controls the

     process state.

    Stores in protected memory area of the

    kernel.

    Consists of the information about the

     process state

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    13/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    13

    Information about the process stateInformation about the process state

    at Process Control Block…at Process Control Block…

    Process ID,

     process priority,

     parent process (if any),

    child process (if any), and

    address to the next process PCB which

    will run,

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    14/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    14

    Information about the process stateInformation about the process state

    at Process Control Block…at Process Control Block…

    allocated program memory address

     blocks in physical memory and in

    secondary (virtual) memory for the

     process-codes, allocated process-specific data address-

     blocks

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    15/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    15

    Information about the process stateInformation about the process state

    at Process Control Block…at Process Control Block…

    allocated process-heap (data generated

    during the program run) addresses,

    allocated process-stack addresses for the

    functions called during running of the process,

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    16/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    16

    Information about the process stateInformation about the process state

    at Process Control Block…at Process Control Block…

    allocated addresses of CPU register-save

    area as a process context represents by CPUregisters, which include the programcounter and stack pointer 

    allocated addresses of CPU register-savearea as a process context

    [Register-contents (define process context) includethe program counter and stack pointer contents]

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    17/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    17

    Information about the process stateInformation about the process state

    at Process Control Block…at Process Control Block…

     process-state signal mask [when mask

    is set to 0 (active) the process is

    inhibited from running and when reset

    to 1, the process is allowed to run], Signals (messages) dispatch table

    [process IPC functions],

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    18/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    18

    Information about the process stateInformation about the process state

    at Process Control Block…at Process Control Block…

    OS allocated resources’ descriptors

    (for example, file descriptors for open

    files, device descriptors for open

    (accessible) devices, device-bufferaddresses and status, socket-descriptor

    for open socket), and

    Security restrictions and permissions.

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    19/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    19

    ContextContext Context loads into the CPU

    registers from memory when process starts running, and the

    registers save at the addresses of

    register-save area on the context

    switch to another process

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    20/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    20

    ContextContext The present CPU registers, which include

     program counter and stack pointer are

    called context

    When context saves on the PCB pointed

     process-stack and register-save areaaddresses, then the running process stops.

    Other process context now loads and that

     process runs ! 

    This means that the contexthas switched

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    21/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    21

    SummarySummary

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    22/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    22

    We learntWe learnt Application program can be said to

    consist of number of processes

    Process defined as that executing unit of

    of computation that processes on a

    CPU and state of which is under thecontrol of kernel of an operating

    system.

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    23/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    23

    We learntWe learnt Process state at an instance defines by

     process-status (running, blocked, or

    finished), process-structure —its data,

    objects and resources and process

    control block .

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    24/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    24

    We learnt

    • OS lets a process execute on the CPU ! 

    some process at OS for a resource-management mechanism lets it use the

    system-memory and other system-

    resources such as network, file, display

    or printer

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    25/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    25

    We learnt

    • PCB ! a data structure having the

    information using which the OScontrols the process state

    • PCB consists of the information aboutthe process state

    • PCB stores in protected memory area

    of the kernel

  • 8/19/2019 Chap 7Lesson01EmsysNewProcess

    26/26

    2008 Chapter-7 L1: "Embedded Systems - Architecture, Programmingand Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

    26

    End of Lesson 1 of Chapter 7End of Lesson 1 of Chapter 7