Presentation is loading. Please wait.

Presentation is loading. Please wait.

Process Management Process Concept Why only the global variables?

Similar presentations


Presentation on theme: "Process Management Process Concept Why only the global variables?"— Presentation transcript:

1 Process Management Process Concept Why only the global variables?
Why only the descriptors? The local variables are kept in the stack. The files could be large and not fit into the memory or any buffer. So only the file’s current status is kept (pointer to the file’s block, file handle, buffer’s address, …

2 Many processes in the same RAM
Address Space - A group of memory addresses used by something (process, module,…) How many different address spaces we see in the RAM?

3 PIDs Process Tree Most operating systems identify processes according to a unique process identifier (or pid). The pid can be used as an index to access various attributes of a process within the kernel. During the course of execution, a process may create several new processes. The creating process is called a parent process the new processes are called the children of that process. Each of these new processes may in turn create other processes, forming a tree of processes. The init process (which always has a pid of 1) serves as the root parent process for all user processes.

4 Process Table To keep track of the state of all the processes, the operating system maintains a table known as the process table. Inside this table, every process is listed along with the resources the process is using and the current state of the process.

5

6 Looking at the Process Tree

7 Another Look at the Process Tree

8 Process Control Block PCB, TCB
PCB is the repository of process. Everything about the processes in the system is kept in PCBs PCB is a container of the Process Context If the OS kernel supports threads then the system could manage also TCBs. The whole PCB collection is called Process Table. PCB contains many pieces of information associated with a specific process

9 PCB content Pointer to the next PCB i.e. pointer to the PCB of the next process to run. Process state: The state may be new, ready, running, waiting, halted, and so on. Process number: The identifier of the process (PID). Program counter: The counter indicates the address of the next instruction to be executed for this process. Pointer to next PCB CPU registers: The registers vary in number and type, depending on the computer architecture. They include: Accumulators index registers stack pointers general-purpose registers any condition-code information. Along with the program counter, this state information must be saved when an interrupt occurs, to allow the process to be continued correctly afterward.

10 PCB content Memory-management information: The memory translation map.
the value of the base and limit registers the page tables the segment tables CPU-scheduling information: process priority pointers to scheduling queues and any other scheduling parameters. Process accounting information such as when the process was last run how much CPU and real time it has accumulated time limits. I/O Information I/O devices allocated to this process list of opened files, etc Pointer to next PCB

11 Process Scheduling The responsibility of determining how to allocate processor time among all the ready processes is known as scheduling (CPU time scheduling). The objective of multiprogramming is to have some process running at all times, so as to maximize CPU utilization. The objective of time-sharing is to switch the CPU among processes so frequently that users can interact with each program while it is running. A uniprocessor system can have only one running process. If more processes exist, the rest must wait until the CPU is free and can be rescheduled.

12 Process States Waiting: wait for some event to occur
such as an I/O completion or reception of a signal. Ready: The process is waiting for permission to use the CPU. waiting and ready states are implemented as queues which hold the processes in these states Terminated: The process has finished execution. New: The process is being created. Running: Instructions are being executed on CPU. process has all the resources it needs for execution Only one process can be in the running state at any given time

13 Process States on Unix %CPU The task's share of the CPU time expressed as a percentage of total CPU time. %MEM The task's share of the physical memory. VSZ The total amount of virtual memory used by the task in kilobytes. RSS The total amount of physical memory used by the task in kilobytes. START start time of task. STAT The process state.

14 Process States on Unix PROCESS STATE CODES
D - uninterruptible (unkillable) sleep (usually I/O processes) – waiting queue R - runnable - these processes now are working – ready queue S - sleeping - these processes are not running but they are active and wait to serve requests –waiting queue T - traced or stopped Z - a defunct ("zombie") process - this process tried to die, partially is dead but its name exists in process list

15 Scheduling Queues Two types of queues are present: the ready queue and a waiting queue. The waiting queue could be represented as a set of device queues. The list of processes waiting for a particular I/O device is called a device queue. Each device has its own device queue.

16 Another view how the processes are put on different queues

17 Processes leaving CPU Who invokes the I/O request? Blocking I/O Call
Once the process is assigned to the CPU and is executing, one of several events could occur: The process could issue an I/O request, and then be placed in an I/O queue. The process could create a new subprocess and wait for its termination. The process could be removed forcibly from the CPU, as a result of an interrupt, and be put back in the ready queue. Who invokes the I/O request? Blocking I/O Call Non Blocking I/O call ? Who invokes fork? Blocking Fork Non Blocking Fork ? Where is the child ? Child Wait Interrupt ? Parent New process arrived I/O of other process is finished

18 Concurrent and parallel processes
Parallelism is when the processes run simultaneously. Concurrent processes could run simultaneously or interleaving What is the main problem of concurrency and how it’s resolved ? The hardware is single. Solution: Multiplex the processes in time on the same hardware Make illusion of multiple CPUs each of which is dedicated for the appropriate process. All non CPU resources (I/O devices and memory) are shared by virtual CPUs I/O Devices

19 Multiprogramming vs. Multiprocessing
Parallelism ? Concurrency ? Batch Processing Multiprogrmming Why some tasks take longer to run? Time Sharing Will the process leave CPU before time slice expires?

20 Context Switch Switching the CPU to another process requires:
saving the state of the old process and loading the saved state for the new process. This task is known as a context switch. PCBs are loaded. New translation map is loaded Context-switch time is pure overhead because the system does no useful work while switching

21 Stack push example on x86 assembly

22


Download ppt "Process Management Process Concept Why only the global variables?"

Similar presentations


Ads by Google