System calls and System call types in operating system

Views 1

In this video i explain what are system calls in operating system with an example and different types of system calls.
System calls provide an interface between user programs and operating system.
It is a programmatic way in which a computer program requests a service from the kernel of the operating system.

Let us first understand the 2 modes in which a program executes.
1)User mode
2)Kernel mode

When a program is executing in user mode, it is not in privileged mode. So whenever it needs any hardware resource like RAM or printer, it needs to make a call to the kernel and this is known as SYSTEM CALL.

When a program is executing in kernel mode, it is executing in privileged mode. So it can access any hardware resource. So when a program needs to access any resource while it is running in user mode it makes a System Call to the kernel then a context switch occurs which takes the program from user mode to kernel mode. After the resource is accessed one more context switch occurs which takes back the program’s execution to user mode.

Now you may wonder why aren’t all programs occurring in kernel mode so we can skip the context switching. This is because if a program crashes in kernel mode entire system will be halted. So most programs are executed in user mode because if it crashes there, entire system won’t be affected.

Now let us take an example.

If we want to write a program to copy the content of one file into another then, first of all this program will need the names of these files. User will give these names by either typing them in the console or selecting them by using GUI. So our program will need to make system calls to the kernel to enable it to access the input and output devices.

Also our program will need to display certain message if the program is successfully completed or even if it stops and is aborted. All these tasks require System calls.

TYPES OF SYSTEM CALLS

A) Process Control

Processes need to be controlled as in a running process must be able to halt its execution either normally or abnormally.Also one process may need to run some other process to complete its own execution. So all these system calls come under this category.

1)end, abort
2)load, execute
3)create process, terminate process
4)get process attributes, set process attributes
5)wait for time, wait event, signal event
6)allocate and free memory

B) File Management

System calls which deal with operations related to files fall under this type.

1)create file, delete file
2)open, close
3)read, write, reposition
4)get file attributes, set file attributes

C) Device Management

A process may need several resources for its execution. So system calls used for asking permission from the kernel to use those resources are included in this type.

1)request device, release device
2)read, write, reposition
3)get device attributes, set device attributes
4)logically attach or detach devices

D) Information Maintenance

We need to keep all the information up to date so these system calls help us to do that.

1)get time or date, set time or date
2)get system data, set system data
3)get process, file, or device attributes
4)set process, file, or device attributes

E) Communication

Processes need to communicate with each other for many reasons like if they need certain resource which is held by any other process. These system calls assist in doing so.

1)create, delete communication connection
2)send, receive messages
3)transfer status information
4)attach or detach remote devices

Share This Video


Download

  
Report form