PROCESS DESCRIPTION & CONTROL
Transcript of PROCESS DESCRIPTION & CONTROL
![Page 1: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/1.jpg)
PROCESS DESCRIPTION & CONTROL
CHAPTER 2
CCS21203 OPERATING SYSTEM
![Page 2: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/2.jpg)
Contents
A. Introduction of Process B. Process Description Control structure
Types of tables C. Process Control
i. Model of execution ii. process Creation iii. Process switching iv. Change of process state v. Execution of operating system
![Page 3: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/3.jpg)
Recall on previous topic
The OS is viewed as ___________ that manage the system resources (???) by process.
Figure 1.1: Basic Diagram of Process and Resources
![Page 4: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/4.jpg)
Introduction of Process
Process Thread Multithreading
An instance of execution of a program
A lightweight process which unit is smaller than a process. A thread is the entity within a process that can be scheduled for execution.
Allows application to manage a separate process with several threads of control
Requires main memory space during execution
Run in a shared memory space of a process
-
Passes through states such as running, ready, or waiting from its initial arrival into the computer system to its completion
Each thread maintains exception handlers, a scheduling priority, thread local storage, a unique thread identifier, and a set of structures the system will use to save the thread context until it is scheduled.
-
Each process is started with a single thread, often called the primary thread, but can create additional threads from any of its threads.
The thread context includes the thread's set of machine registers, the kernel stack, a thread environment block, and a user stack in the address space of the thread's process.
-
![Page 5: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/5.jpg)
Introduction of Process
• Elements of a process Program code May be shared with other processes that are executing the same
program
A set of data associated with the code When the processor begins to execute the program code, we refer
to this executing entity as a process
![Page 6: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/6.jpg)
Process Control Block
For each process there is a Process Control Block, PCB, which stores the following
Process State Process ID, and parent process ID. CPU registers and Program Counter - These need to be saved
and restored when swapping processes in and out of the CPU. CPU-Scheduling information - Such as priority information
and pointers to scheduling queues. Memory-Management information - Page tables or segment
tables. Accounting information - user and kernel CPU time consumed,
account numbers I/O Status information - Devices allocated, open file tables.
![Page 7: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/7.jpg)
Process States
Processes may be in one of 5 states: New/Hold - The process is in the stage of being created. Ready - The process has all the resources available that it
needs to run, but the CPU is not currently working on this process's instructions.
Running - The CPU is working on the process's instructions. Waiting - The process cannot run at the moment, because it is
waiting for some resource to become available or for some event to occur. For example the process may be waiting for keyboard input, disk access request, inter-process messages, a timer to go off, or a child process to finish.
Finished - The process has completed and return to the user.
![Page 8: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/8.jpg)
Control Structure
An operating system, as a service provider, naturally also imposes control on processes that consume the services. That is both processes and resources are under the operating system’s control.
To enable this control, some facilities must be
provided, which is control tables.
![Page 9: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/9.jpg)
![Page 10: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/10.jpg)
![Page 11: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/11.jpg)
Types of control tables
i. Memory table
ii. I/O table
iii. Files table
iv. Process table
![Page 12: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/12.jpg)
i) Memory Table
To keep track of both main memory and secondary memory. Part of main memory is reserved to be used by the operating system while the remainder is available to be used by processes. Processes may also resize on secondary memory due to the utilization of swapping mechanism. The memory tables generally include the following information:
a. The allocation of main memory to processes b. The allocation of secondary memory to
processes c. Protection attributes of blocks of main or
virtual memory.
![Page 13: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/13.jpg)
Swapping mechanism
Involves moving part of a process from main memory to secondary memory (disk).
When none of the processes in main memory is in the Ready state, the OS swaps one of the blocked processes out on to disk into a suspend queue.
![Page 14: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/14.jpg)
Why process is suspended? 5 possible reasons
![Page 15: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/15.jpg)
Differences between main and virtual memory
Main memory Physical DRAM SRAM
Virtual memory Originally invented to accommodate programs requiring more
memory than the physical memory. Replacement controlled by the operating system not hardware
![Page 16: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/16.jpg)
ii) I/O tables
Are used by the operating system to manage I/O devices. Used by the OS to manage channels of the computer
system At any given time, an I/O device may be available or
assigned to a particular process
They should record: The availability of each particular device The status of I/O operations relating to each device The location in main memory ; either is being used as the source or
destination of the I/O transfer
![Page 17: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/17.jpg)
iii) Files tables
Information is maintained and used by a file management system in which case the OS has little or no knowledge of files in other operating systems, much of the detail of file
management is managed by the OS itself
Files tables must have the information of: The existence of files Their (the file) location on secondary Their (the file) current status and Other attributes
![Page 18: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/18.jpg)
iv) Process tables
Must be maintained to manage processes There must be some reference to memory, I/O, and files, directly or
indirectly The tables themselves must be accessible by the OS and therefore
are subject to memory management Contains what the operating system must know to manage and
control processes, including: i. Process location ii. Process attributes iii. Process identification (Process ID) iv. Process state information (Process State) v. Process control information (process CI) This may include scheduling and state information, data
structuring, process privileges, and resource ownerships.
![Page 19: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/19.jpg)
Process Control 1. Model of execution 2. Process Creation and
termination 3. Process switching 4. Change of process state 5. Execution of operating system
![Page 20: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/20.jpg)
Kernel Mode and User Mode
..\LECTURE\CHAPTER_1_forstudent.pptx Page 29
![Page 21: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/21.jpg)
Process creation and termination
Process spawning When the OS create a process at explicit request of another
process
Parent process The original process that create a process
Child process Is a process created by the parent process
![Page 22: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/22.jpg)
Process creation
![Page 23: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/23.jpg)
Process Termination
There must be a means for a process to indicate its completion
A batch job should include a HALT instruction or an explicit OS service call for termination
For an interactive application, the action of the user will indicate when the process is completed (e.g. log off, quitting an application)
![Page 24: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/24.jpg)
Process switching
A process switch may occur any time that the OS has gained control from the currently running process. Possible events giving OS control are:
![Page 25: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/25.jpg)
Modes of switching
![Page 26: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/26.jpg)
Interrupts
READ and WRITE command is issued to the CPU. Occur as a direct result of arithmetic operation: Attempt to divide by zero Floating-points operations generating an overflow or
underflow Fixed point addition or subtraction that cause arithmetic
overflow
Illegal job instructions, such as the following: Attempt to access protected or nonexistent storage location Attempt to use undefined operation code Operating on invalid data Attempt to make system changes
![Page 27: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/27.jpg)
OVERFLOW and UNDERFLOW
Floating point operation generating an overflow or underflow is one of the interrupt reasons. Example of arithmetic operation overflow and underflow. If a numbers is represented using 4 bits as unsigned
binary, the minimum value is 0 (i.e., 00002, while the maximum value is 15 (11112).
Any operation that results in a number larger than 15 is overflow.
An operation that is smaller than 0 is underflow. For example, if you summed 14 + 14, the resulting
value is 28. but the value 28 has no representation using 4 bits
since the maximum representable value is 15 .
![Page 28: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/28.jpg)
Process switching steps
1. Save the context of the processor 2. Update the related fields in the (process control
block) PCB, e.g. the state of the process. 3. Move the PCB to the appropriate queue. 4. Select another process for execution. 5. Update the PCB of the process selected. 6. Update memory management data 7. Restore the context of the processor to the one
when this selected process was last switched out.
![Page 29: PROCESS DESCRIPTION & CONTROL](https://reader030.fdocuments.us/reader030/viewer/2022012714/61ad2d960953664b0e7522ff/html5/thumbnails/29.jpg)
Conclusion
It encourages the use of a modular operating system with clean interfaces between the modules.
Some noncritical operating system functions are conveniently implemented as separate processes.
The form of processes makes it possible to distribute different parts of the operating system in a multiprocessor environment, improving performance.