System Calls

A system call is the programmatic way in which a computer program requests a service from the kernel of the operating system it is executed on. In other words, a system call is a way for programs to interact with the operating system. A computer program makes a system call when it makes a request to the operating system’s kernel. System call provides the services of the operating system to the user programs via Application Program Interface(API). It provides an interface between a process and operating system to allow user-level processes to request services of the operating system. System calls are the only entry points into the kernel system. All programs needing resources must use system calls


1. create()

This system call is used to create a new file. It creates a new file on disk, creates a file table entry, then sets the first unused file descriptor to point to the table file entry and then return it (or -1 upon failure).

2. open()

This system call can be used to open a file, for either reading or writing purposes. The working principle in the OS is similar to that of create() , except for the first step. Instead of creating a file on the disk , it first reads the file from the disk.

3. close()

This system call takes in a file descriptor (The ones created by the above two commands) and then closes the file which is pointed at by this file descriptor.

4. read()

This system call reads a certain number of bytes (passed as parameters) into the ‘buf’ memory area. It updates the access time for the file as well.

5. write()

This system call takes a file descriptor and a buffer and writes a certain number of bytes ( all 3 passed as parameters ) to the file associated with this file descriptor.

6. lseek()

This system call is used to shift the location of the pointer of a file descriptor. This location can be set in either relative terms or absolute terms.

7. dup()

This system call creates a copy of the file descriptor passed to it. This copy is exactly the same as the original. Both of them can be used interchangeably.

8. link()

This system call creates a new directory entry for an existing file.

9. unlink()

As the name suggests, this system does the opposite of what link() does. It simply removes the directory entry for an existing file

10. access()

This system call checks whether or not the calling process can access a specific file or not (Passed to the call by as a parameter)

11. chmod()

This system call is used to change the file’s mode bits (These are the bits which specify the access control for the file Who can do what kind of changes to the file) It takes in the path of the file whose permissions we want to change.

12. chown()

This system call is used to change the owner and/or the group of the file (passed through a path or a file descriptor). Only a privileged process can change the
ownership of a file.

13. unmask()

This system call sets the calling process's file mode creation mask (umask) to mask & 0777. Basically, it helps us to define the default protection/access modes for any new files that we create.

14. ioctl()

This system call manipulates the underlying device parameters of special files. For example, in Linux, many characteristics of character special files (The terminal is one such entity), can be controlled using requests made through this system call.

15. execl()

This system call is used to launch/execute a program/file. It works by overriding the current process image with one of that which is launched.

16. fork()

This command is used for making child processes that run parallely along with the process that created them. After a new process is created, both processes execute the next instruction following the fork system call.

17. wait()

This system call blocks the parent process until one of its child processes exits, or an exit signal is received. After the child process terminates, the parent can continue with its own execution.

18. exit()

This system call is used to terminate a process normally. When this system call is made. Any file descriptors related to the file in questions are closed and the Children of this process are inherited by process 1 , init.

19. chdir()

This system call is used to change the current working directory.

20. alarm()

This system call causes the program to generate a SIGALRM signal for the process after a certain number of seconds have elapsed.

21. kill()

This command kills the process group of the caller

22. signal()

This system call installs a new signal handler for the signal with number signum.

23. getppid()

This system call returns the process ID (PID) of the parent of the calling process.

24. getpid()

This system call returns the process ID (PID) of the calling process.

25. getgid()

This system call returns the real Group ID of the current process.

26. geteuid()

This system call returns the effective user ID of the current process.

27. getuid()

This system call return the REAL user ID of the current process.