INTRODUCT ION
SystemCalls provide the Interface between a process and the
Operating System.
These calls are generally available as Assembly language
instruction.
System Calls can also be made directly through HLL programs
for certain systems.
UNIX System calls can be invoked directly from a C or C++
program.
5.
S TRUCTURE OFS YSTE M CAL LS
•User requests a system call (e.g., read()).
•Request goes to OS via a software
interrupt.
•Kernel handles the request and returns a
result to user space.
6.
6
HOW S YSTEM CAL LS OCCUR.
System Calls occur in different ways depending on the computer
in use:
o More information is required than just the identify of the
desired System call.
o The exact type and amount of information varies according to
the operation system and call
o For instance to get an input we need to specify the file of device
to use as source and the address and length of memory buffer
7.
7
CAT EGORIES OFSYS TEM CALL S
System calls can be grouped into five major categories as
follows.
o Process control
o File management.
o Device management
o Information Maintenance
o Communication.
8.
8
PROCES S CONTROL
Somesystem calls under process control
are:
o End, abort
o Load, execute
o Create process, terminate process
o Get process, terminate process
o Wait for time
o Allocate and free memory
9.
9
FI LE MANAGEM ENT
Some system calls under file
management are:
o Create file, delete file
o Open , close
o Read, write, reposition.
o Get file attributes, set fil attributes
10.
10
DEVICE M ANAGEMENT
Some system calls under device management
are:
o Request Device, release device
o Read, write, reposition.
o Get device attributes and set device attributes
o Logically attach or detach devices
11.
11
INFOR MATI ONM AINTENANCE
Some system calls under information maintenance are:
o Get time or date, Set time of date
o Logically attach or detach devices
o Information maintenance
o Get system data, Set Systems data
o Get process, file of device attributes
o Set process, file or device attributes
12.
12
COM M UNICATI ON
o Create, delete communication
connection.
o Send, receive messages
o Transfer status information
o Attach or detach remote devices.
13.
13
EXAM PL EOF S YS TEM CALL S I N LI NUX
🔹 int fd = open("file.txt", O_RDONLY);
What it does:
Opens the file "file.txt" in read-only mode.Returns a file
descriptor (fd): a non-negative integer if successful, or -1 if
an error occurs.
🔹 ssize_t bytes = read(fd, buffer, size);
What it does:
Reads up to size bytes from the file referred to by
fd into buffer.Returns the number of bytes read, or
-1 on error.
🔹 pid_t pid = fork();
What it does:
Creates a new child process.Returns:>0 to the
parent (child's PID)0 to the child-1 on failure
OUTPUT :
14.
CONCL US ION
•System calls are essential for OS functionality.
•Provide a bridge between applications and hardware.
•Understanding system calls is crucial for low-level
programming and OS development.