26
2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 1 Inter-Process Communication and Synchronization of Processes, Threads and Tasks: Lesson-1: PROCESS

Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

1

Inter-Process Communication and Synchronization of Processes,

Threads and Tasks:

Lesson-1: PROCESS

Page 2: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

2

Process ConceptsProcess Concepts

Page 3: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

3

ProcessProcess� A process consists of executable

program (codes), state of which is controlled by OS,

� The state during running of a process─represented by process-status (running, blocked, or finished), process-structure—its data, objects and resources, and process control block (PCB).

Page 4: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and 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….

Page 5: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and 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 …

Page 6: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

6

Application program can be said to Application program can be said to consist of number of processesconsist of number of processes

Page 7: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and 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 program objects that must be concurrently processed on a single processor.

Page 8: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

8

� Voice encoding and convoluting process─ the device captures the spoken words through a speaker and generates the digital signals after analog to digital conversion, the digits are encoded and convoluted using a CODEC,

� Modulating process, � Display process,

Exemplary processes at the phone deviceExemplary processes at the phone device

Page 9: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

9

� GUIs (graphic user interfaces), and � Key input process ─ for provisioning

of the user interrupts

Exemplary processes at the phone deviceExemplary processes at the phone device

Page 10: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

10

ProcessProcess

Page 11: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

11

Process Control BlockProcess Control Block

Page 12: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

12

Process Control Block Process 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

Page 13: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

13

Information about the process state Information 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,

Page 14: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

14

Information about the process state Information 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

Page 15: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

15

Information about the process state Information 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,

Page 16: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

16

Information about the process state Information 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 CPU registers, which include the program counter and stack pointer

� allocated addresses of CPU register-save area as a process context

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

Page 17: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

17

Information about the process state Information 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],

Page 18: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

18

Information about the process state Information 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-buffer addresses and status, socket-descriptor for open socket), and

� Security restrictions and permissions.

Page 19: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and 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

Page 20: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and 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 area addresses, then the running process stops.

� Other process context now loads and that process runs─ This means that the context has switched

Page 21: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

21

SummarySummary

Page 22: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

22

We learnt We 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 the control of kernel of an operating system.

Page 23: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

23

We learnt We 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.

Page 24: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and 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

Page 25: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

25

We learnt • PCB─ a data structure having the

information using which the OS controls the process state

• PCB consists of the information about the process state

• PCB stores in protected memory area of the kernel

Page 26: Lesson-1 · 10 Process. 2008 Chapter-7 L1: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11 Process Control Block. 2008 Chapter-7

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

26

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