0% found this document useful (0 votes)
148 views21 pages

UNIX System Calls Overview

Uploaded by

220047
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
148 views21 pages

UNIX System Calls Overview

Uploaded by

220047
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

System Calls

What is a System Call?


 System call is a way for programs to interact with the operating system.
 the only entry points into the kernel system
 provides the services of the operating system to the user programs via
Application Program Interface(API).
 enable interaction with the operating system's services, managing resources, and
executing privileged operations.
System calls in UNIX
There are mainly 6 types of system calls available:
• Process Control
• File Management
• Device Management
• Information Maintenance
• Communication
• Protection
Process Control
 The system call that is used to direct the processes.
 Some of them include:

fork()
 Processes generate clones of themselves using fork(). It is one of the most
common ways to create processes in operating systems. When a parent process
spawns a child process, the execution of the parent process is interrupted until
the child process completes. Once the child process has completed its
execution, control is returned to the parent process.
exec()
 When an executable file replaces an earlier executable file in an already executing
process, this system function is invoked. As a new process is not built, the old
process identification stays, but the new process replaces data, stack, data, head, etc.

wait()
 When a parent process makes a child process, the parent process execution is
suspended until the child process is finished. The wait() system call is used to
suspend the parent process. Once the child process has completed its execution,
control is returned to the parent process.
exit()
 The exit() is a system call that is used to end program execution. This call indicates
that the thread execution is complete and the operating system reclaims resources
spent by the process.
File Management
 File management is a system call that is used to handle the files.
 Some of them are:
open()
 The open() system call allows you to access a file on a file system. It allocates
resources to the file and provides a handle that the process may refer to.

read()
 It is used to obtain data from a file on the file system
It accepts three arguments in general:
1. A file descriptor.
2. A buffer to store read data.
3. The number of bytes to read from the file.
 The file descriptor of the file to be read could be used to identify it and open it
using open() before reading

write()
 It is used to write data from a user buffer to a device like a file. This system call is one
way for a program to generate data. It takes three arguments in general:
1. A file descriptor.
2. A pointer to the buffer in which data is saved.
3. The number of bytes to be written from the buffer.
close()
 It is used to end file system access. When this system call is invoked, it signifies that
the program no longer requires the file, and the buffers are flushed, the file
information is altered, and the file resources are de-allocated as a result.
Device Manipulation
 Device management is a system call that is used to deal with devices.
 Some of them are:

read(): The read() system call is used to read data from a device into a buffer in
memory.

ioctl(): The ioctl() (input/output control) system call is used for device-specific
input/output operations and control commands. It allows processes to send control
commands to devices and query or set device parameters.
 write(): The write() system call is used to write data from a buffer in memory to a
device.
Information Maintenance
 Information maintenance is a system call that is used to maintain information
 Some of them are:
getpid()
 Returns the process ID (PID) of the calling process. This system call is used to
obtain the unique identifier of the current process.

getppid()
 Returns the parent process ID (PPID) of the calling process. It allows a process
to identify its parent process.
alarm()
 The alarm() system call is used to set an alarm clock for the calling process. It requests
that a SIGALRM signal be sent to the process after a specified number of seconds.
 When the specified number of seconds has elapsed, the process receives a SIGALRM
signal, which can be caught using a signal handler function.
 alarm(0) can be used to cancel any previously set alarm.

sleep()
 The sleep() system call suspends the execution of the calling thread for a specified
number of seconds.
 While the process is sleeping, it does not consume CPU resources, allowing other
processes to execute.
 If no time remains to sleep, the function returns 0.
Communication
 Communication is a system call that is used for communication.
 It includes:
Pipe()
 pipe() system call creates an anonymous pipe, a unidirectional communication
channel that allows data to flow between two related processes. pipe2() is an
enhanced version of pipe() that allows specifying additional flags. Pipes are
often used for communication between a parent process and its child process.
shmget()
 The shmget() system call in Unix is used to allocate a shared memory segment. It
returns a unique identifier (shmid) for the shared memory segment.

mmap()
 The mmap() system call in Unix is used to map files or devices into memory. It
returns a pointer to the mapped memory region.
Protection
 Protection system calls in Unix are a set of functions that allow processes to
manage access permissions, ownership, and other security-related attributes of
various system resources
 Some include:
chmod()
 The chmod() system call in Unix is used to change the permissions of a file or
directory. It returns 0 on success, -1 on failure.
umask()
 The umask() system call in Unix is used to set the file creation mask, which controls
the default permissions assigned to newly created files and directories. It returns the
previous file creation mask.

chown()
 The chown() system call in Unix is used to change the ownership of a file or
directory. It returns 0 on success, -1 on failure.
Conclusion

 System calls provide a crucial interface between user programs and the
operating system.
 Understanding them is essential for system programming, debugging, and
optimizing performance.
References
 https://www.geeksforgeeks.org/introduction-of-system-call/
 https://www.javatpoint.com/system-calls-in-operating-system
 https://www.scaler.com/topics/operating-system/system-calls-in-operating-system/
Presentation by
34.Farhan Byju
36.Fazal Iqbal
38.Girinath P S
40.Haripriya N
42.Joel Daniel
THANK YOU!

You might also like