OS Tech Concepts Lecture 2
OS Tech Concepts Lecture 2
Systems Technology
Operating System Concepts
Overview
Process Concept
Process State
System Calls
Process Control Block (PCB)
Objectives
At the end of this class, you should be able to
define process and explain the process concept
describe the process state and the PCB
describe system calls
Process Concept
What is a Process?
a program in execution
a unit of work within the system
executes instructions sequentially until
completion
execution must progress in a sequential fashion
job and process are commonly interchanged
an entity which represents the basic unit of work
to be implemented in the system.
Process Concept
Simply put
computer program written in a text file
execute this program
it becomes a process (after exceution)
it performs all the tasks mentioned in the
program
Components of a Process
S.N. Component & Description
1 Stack
The process Stack contains the temporary data
such as method/function parameters, return
address and local variables.
2 Heap
This is dynamically allocated memory to a
process during its run time.
3 Text
This includes the current activity represented by
the value of Program Counter and the contents
of the processor's registers.
4 Data
This section contains the global and static
variables.
Process States
A process passes through different states
during execution
These stages may differ in different operating
systems
The names of these states are also not
standardized
In general, a process can have one of the
following five states at a time.
Diagram of Process States
Process States
S.N. State & Description
1 Start
This is the initial state when a process is first started/created.
2 Ready
The process is waiting to be assigned to a processor. Ready processes are waiting to have the processor
allocated to them by the operating system so that they can run. Processes may come into this state
after Start state or while running it by but interrupted by the scheduler to assign CPU to some other
process.
3 Running
Once the process has been assigned to a processor by the OS scheduler, the process state is set to
running and the processor executes its instructions.
4 Wait
Process moves into the waiting state if it needs to wait for a resource, such as waiting for user input, or
waiting for a file to become available.
5 Terminated or Exit
Once the process finishes its execution, or it is terminated by the operating system, it is moved to the
terminated state where it waits to be removed from main memory.
System Calls
Provide an interface between a running program (process) and the OS
provides an interface to the operating system services
Allow user-level processes to request some services from the OS
which the process itself is not allowed to do
are generally available as assembly language instructions (e.g. sys_exit, sys_fork
etc)
For example, for I/O, a process involves a system call telling the operating
system to read from, or to write to a particular area and this request is satisfied
by the operating system.
a request for service made by any program to the kernel for performing tasks,
picked from a predefined set, which the said program does not have the
required permissions to execute in its own flow of execution.
System Calls
Application developers often do not have direct access to the system calls
Can access them through an Application Programming Interface (API)
a set of functions that can be called from an application program to access
features of another program
the software interface to system services or software libraries.
can consist of classes, function calls, subroutine calls, descriptive tags etc
The functions that are included in the API invoke the actual system calls
System Calls
BENEFITS OF USING APIs
Portability: as long a system supports an API, any program using that API
can compile and run.
Ease of Use: using the API can be significantly easier than using the
actual system call.
System Calls - Types
1) Process control: used to control processes. eg: end, abort, load,
execute, create process, terminate process; get process attributes, set
process attributes, wait for time, wait event, signal event, allocate and
free memory.
2) File management: used to manage files. eg: create file(s), delete file(s),
open, close, read, write, reposition, get file attributes, set file attributes.
3) Device Management: Processes usually require several resources to
execute. These resources are also thought of as devices (physical, such
as a video card, and others are abstract, such as a file). User programs
request the device, and when finished they release the device. Similar
to files, we can read, write, and reposition the device.
4) Information maintenance: used to get information from the computer.
eg: get time or date, set time or date; get system data, set system data;
5) Communication: used for communication. eg: create, delete
communication connection; send, receive messages; and transfer status
information.
Process Control Block (PCB)
Data structure maintained by the Operating System for every process.
is identified by an integer process ID (PID)
Information associated with each process is stored in PCB
PCB is maintained for each process so that the OS can know the state or stage it
stopped its previous processing.
The PCB is the key tool that enables the OS to support multiple processes and to
provide for multiprocessing
Contains the following:
Process ID
Process state
Program counter
CPU registers
CPU scheduling information
Memory management information
Accounting information
I/O status information
Process Control Block (PCB)
The architecture of a PCB is
completely dependent on
the OS
May contain different
information in different
operating systems
The PCB is maintained for a
process throughout its
lifetime, and is deleted
once the process
terminates.
Simplified diagram of a PCB
S.N. Information & Description
1
Process Control Block (PCB)
Process State
The current state of the process i.e., whether it is ready, running, waiting, or whatever.
2 Process privileges
This is required to allow/disallow access to system resources.
3 Process ID
Unique identification for each of the process in the operating system.
4 Pointer
A pointer to parent process.
5 Program Counter
Program Counter is a pointer to the address of the next instruction to be executed for this process.
6 CPU registers
Various CPU registers where process need to be stored for execution for running state.
7 CPU Scheduling Information
Process priority and other scheduling information which is required to schedule the process.
8 Memory management information
This includes the information of page table, memory limits,
9 Accounting information
This includes the amount of CPU used for process execution, time limits, execution ID etc.
10 IO status information
This includes a list of I/O devices allocated to the process.
Process Scheduling
Determining which process in the ready state should be moved to the
running state
The goal of the scheduler: Implement the virtual machine in such a way
the user perceives that each process is running on it’s own computer.
Decide which processes in the ready state get the processor next,
when, and for how long
The process scheduler performs the following tasks
1)Keeps track of the status of the process (all processes are either
running, ready, or blocked) performed by traffic controller.
2)Decides which process gets a processor and for how long
performed by the processor scheduler.
3)Allocating a processor to a process. This requires resetting of
processor registers to correspond to the process’ correct state.
This task is performed by the traffic controller.
4)Deallocating a processor performed by the traffic controller
Types of OS - expanded
1) Real-time operating system: designed to run
real-time applications. It can be both single- and
multi-tasking. Application: car air bag control
system, medical imaging systems etc. Examples
include Abbasi, AMX RTOS, etc.
2)Advantages
It works very fast.
It is saves time, as it need not be loaded from memory.
Since it is very small, it occupies less space in memory.
Types of OS - expanded
2) Single-User/Single-Tasking OS: allows a single user
to perform only one task at a time
3)Functions like printing a document, downloading
images, etc., can be performed only one at a time.
Examples include MS-DOS, Palm OS, etc.
4)Advantage
This operating system occupies less space in memory.
5)Disadvantage
It can perform only a single task at a time.
Types of OS - expanded
3) Single-User/Multitasking OS : allows a single user
to perform more than one task at a time
4)Examples include Microsoft Windows and Macintosh
OS.
5)Advantage
It is time saving as it performs multiple tasks at a time yielding high
productivity.
6)Disadvantage
This operating system is highly complex and occupies more space.
Types of OS - expanded
4) Multiuser/Multitasking OS: permits several users to utilize the
programs that are concurrently running on a single network
server.
5)Examples include UNIX
6)Advantages
It is highly productive as it performs multiple tasks at a time.
It is time saving as we don’t have to make changes in many desktops, instead
can make changes only to the server.
7)Disadvantage
If the connection to the server is broken, user cannot perform any task on the
client as it is connected to that server.
Summary
We have learnt that:
a process is a program in execution.
the PCB is composed of
process ID,
process state,
program counter,
CPU registers
scheduling information,
memory management
accounting information,
I/O status information.
Other types of OSs