OS Process State 22.2
OS Process State 22.2
Introduction to Processes
UNIX SYSTEM CALLS DESCRIPTION WINDOWS API CALLS DESCRIPTION
Create a new
fork() Create a new process. CreateProcess()
process.
Terminate the current Terminate the
exit() ExitProcess()
process. current process.
Make a process wait Wait for a process
wait() until its child processes WaitForSingleObject() or thread to
terminate. terminate.
Directory Management
Create a new
mkdir() Create a new directory. CreateDirectory()
directory.
Remove an existing
rmdir() Remove a directory. RemoveDirectory()
directory.
Change the current Change the current
chdir() SetCurrentDirectory()
directory. directory.
Get extended file
stat() Get file status. GetFileAttributesEx()
attributes.
Get file
Get status of an open
fstat() GetFileInformationByHandle() information using a
file.
file handle.
Create a hard link
link() Create a link to a file. CreateHardLink()
to an existing file.
Get the status of an Create a symbolic
symlink() CreateSymbolicLink()
open file. link.
Device Management
Information Maintenance
Communication Calls
Create a new
socket() Create a new socket. socket()
socket.
Bind a socket to a Bind a socket to a
bind() bind()
network address. network address.
Listen for
Bind a socket to a
listen() listen() connections on a
network address.
socket.
Accept a new
Accept a new
accept() accept() connection on a
connection on a socket.
socket.
Initiate a
Initiate a connection on
connect() connect() connection on a
a socket.
socket.
Send and receive data Send and receive
send() or recv() send() or recv()
on a socket. data on a socket.
Security and Access
Control
Change the Change the file
SetFileAttributes() or SetSecurit
chmod() or umask() permissions/mode of a attributes or
yInfo()
file. security info.
1. Process Control
System calls play an essential role in controlling system processes. They enable you to:
2. File Management
System calls support a wide array of file operations, such as:
3. Device Management
System calls can be used to facilitate device management by:
4. Information Maintenance
This type of system call enables processes to:
5. Communication
The communication call type facilitates:
Determining which processes or users get access to specific resources and who can
read, write, and execute resources.
Facilitating user authentication procedures.
BASIS FOR
SYSTEM CALL SYSTEM PROGRAM
COMPARISON
Basic Concept Allow user process to request the Creates an environment for program to
services of operating system. develop and execute.
User View Defines interface to the services of Defines a user interface of operating
operating system. system.
Request It satisfies the low-level request of It satisfies the high-level request of the
user program. user program.
Action Invokes the services of operating Initiates a sequence of system calls for to
system. satisfy a user request.
Language Used Usually written in C and C++. But System program are written in high-level
where direct hardware access is languages only.
required the call is written using
assembly level language.
Process States
1. New:
The process is being created.
2. Ready:
The process is waiting to be assigned to a processor.
3. Running:
Instructions are being executed.
4. Waiting:
The process is waiting for some event to occur (e.g., I/O completion).
5. Terminated:
The process has finished execution.
Data structure used by the operating system to manage information about a process.
Contains:
Process state.
Program counter.
CPU registers.
CPU scheduling information.
Memory management information.
I/O status information.
Accounting information.
Process Scheduling
1. Definition:
The process of determining which process will execute next on the CPU.
2. Goals:
Fairness.
Efficiency.
Responsiveness.
3. Scheduling Algorithms:
First-Come, First-Served (FCFS):
Processes are executed in the order they arrive.
Shortest Job Next (SJN):
Processes are executed based on their burst time.
Round Robin:
Each process is given a small unit of CPU time, and then moved to the
end of the queue.
Priority Scheduling:
Processes are executed based on priority levels assigned to them.
Process Synchronization
1. Definition:
Coordination of multiple processes that may be competing for resources.
2. Issues:
Race conditions.
Deadlocks.
Starvation.
3. Synchronization Mechanisms:
Mutexes:
Binary semaphore used to ensure mutual exclusion.
Semaphores:
Integer variable used for signaling between processes.
Monitors:
High-level synchronization construct that encapsulates shared data and
operations.
1. Definition:
Mechanisms for processes to communicate and synchronize their actions.
2. Types:
Shared Memory:
Processes share a region of memory.
Message Passing:
Processes exchange messages via a communication channel.
Pipes and FIFOs:
Unidirectional communication between related processes.
Sockets:
Communication between processes over a network.