PROCESS DESCRIPTION & CONTROL

29
PROCESS DESCRIPTION & CONTROL CHAPTER 2 CCS21203 OPERATING SYSTEM

Transcript of PROCESS DESCRIPTION & CONTROL

Page 1: PROCESS DESCRIPTION & CONTROL

PROCESS DESCRIPTION & CONTROL

CHAPTER 2

CCS21203 OPERATING SYSTEM

Page 2: PROCESS DESCRIPTION & CONTROL

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

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

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

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

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.

Presenter
Presentation Notes
Pages: a process that is divided into parts before loaded into memory Segment: pieces that perform related function
Page 7: PROCESS DESCRIPTION & CONTROL

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

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
Page 10: PROCESS DESCRIPTION & CONTROL
Page 11: PROCESS DESCRIPTION & CONTROL

Types of control tables

i. Memory table

ii. I/O table

iii. Files table

iv. Process table

Page 12: PROCESS DESCRIPTION & CONTROL

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

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

Why process is suspended? 5 possible reasons

Page 15: PROCESS DESCRIPTION & CONTROL

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

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

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

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

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

Kernel Mode and User Mode

..\LECTURE\CHAPTER_1_forstudent.pptx Page 29

Page 21: PROCESS DESCRIPTION & CONTROL

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

Process creation

Page 23: PROCESS DESCRIPTION & CONTROL

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

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

Modes of switching

Page 26: PROCESS DESCRIPTION & CONTROL

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

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

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.

Presenter
Presentation Notes
Context switching is the procedure of storing the state of an active process for the CPU when it has to start executing a new one. For example, process A with its address space and stack is currently being executed by the CPU and there is a system call to jump to a higher priority process B; the CPU needs to remember the current state of the process A so that it can suspend its operation, begin executing the new process B and when done, return to its previously executing process A.
Page 29: PROCESS DESCRIPTION & CONTROL

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.