0% found this document useful (0 votes)
7 views

OS Process State 22.2

Uploaded by

mathscribd66
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

OS Process State 22.2

Uploaded by

mathscribd66
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Lecture Notes: Operating System Process Management

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.

CreateProcess() or Execute a new


Execute a new program
exec() program in a new
in a process.
ShellExecute() process.
Get the unique process Get the unique
getpid() GetCurrentProcessId()
ID. process ID.
File Management
Open or create a
open() Open a file (or device). CreateFile()
file or device.
Close an open file (or Close an open
close() CloseHandle()
device). object handle.
Read from a file (or Read data from a
read() ReadFile()
device). file or input device.
Write to a file (or Write data to a file
write() WriteFile()
device). or output device.
Change the read/write Set the position of
lseek() SetFilePointer()
location in a file. the file pointer.
Delete an existing
unlink() Delete a file. DeleteFile()
file.
Move or rename a
rename() Rename a file. MoveFile()
file.

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

VirtualAlloc() or Reserve, commit,


Increase/decrease the
brk() or sbrk() or free a region of
program's data space.
VirtualFree() memory.
Map a file into the
Map files or devices
mmap() MapViewOfFile() application's
into memory.
address space.

Information Maintenance

Get the current


time() Get the current time. GetSystemTime()
system time.
Get the status of an
alarm() SetWaitableTimer() Set a timer object.
open file.
GetUserName() or
Set an alarm clock for Get the username
getuid()
the delivery of a signal. LookupAccountName() or ID.

Get the group


getgid() Get the group ID. GetTokenInformation() information of a
security token.

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.

Change the owner and Set the security


chown() SetSecurityInfo()
group of a file. information.
Types of System Calls
The following list categorizes system calls based on their functionalities:

1. Process Control
System calls play an essential role in controlling system processes. They enable you to:

 Create new processes or terminate existing ones.


 Load and execute programs within a process's space.
 Schedule processes and set execution attributes, such as priority.
 Wait for a process to complete or signal upon its completion.

2. File Management
System calls support a wide array of file operations, such as:

 Reading from or writing to files.


 Opening and closing files.
 Deleting or modifying file attributes.
 Moving or renaming files.

3. Device Management
System calls can be used to facilitate device management by:

 Requesting device access and releasing it after use.


 Setting device attributes or parameters.
 Reading from or writing to devices.
 Mapping logical device names to physical devices.

4. Information Maintenance
This type of system call enables processes to:

 Retrieve or modify various system attributes.


 Set the system date and time.
 Query system performance metrics.

5. Communication
The communication call type facilitates:

 Sending or receiving messages between processes.


 Synchronizing actions between user processes.
 Establishing shared memory regions for inter-process communication.
 Networking via sockets.

6. Security and Access Control


System calls contribute to security and access control by:

 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.

Classification Process control, File management,


file manipulation, status information,
file modification,
device manipulation, Programming-language support,
information maintenance, program loading and execution,
communications, and protection. communication
1. Definition:
 A process is an executing instance of a program.
2. Characteristics:
 Independent entity.
 Has its own address space.
 Can execute concurrently with other processes.

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.

Process Control Block (PCB)

 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.

Inter-Process Communication (IPC)

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.

You might also like