(Open in Desktop/Laptop/Big Screen for better result.)
Title: Write a program to demonstrate use of Process Control system calls.
Theory:
➤ System call:
A system call is a mechanism that provides the interface between a process and the operating system. It is a programmatic method in which a computer program requests a service from the kernel of the OS.
➤ List process control systemcalls for windows as well as unix operating system.
1. For Windows:
Process control system calls for windows:
CreateProcess()
ExitProcess()
WaitForSingleObject()
2. For Linux:
Process control system calls for windows:
fork()
exit()
wait()
➤ Code / Program:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unlisted.h>
int main()
{
//make two process, which run same program after this instruction
fork();
printf("Hello world: from %d/n", getpid());
return 0;
}
➤ Steps to execute above code:
(We assumed that you have save the file with .c extension and you know the path of this file)
Step 1: Open terminal, Use cd command to move to the directory in which your file is there.
Step 2: Type gcc file_name.c and press enter, then type ./a.out to get the output.
Conclusion:
➼ Importance of system calls. And name all system calls that you have learnt along with their usage. System call provides the services of the operating system to the user programs via Application Programnterface(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.
I) Process Control: These system calls deal with processes such as process creation, process termination etc.
II) File Management: These system calls are responsible for file manipulation such as creating a file, reading a file, writing into a file etc.
III) Device Management: These system calls are responsible for device manipulation such as reading from device buffers, writing into device buffers etc.
IV) Information Maintenance: These system calls handle information and its transfer between the operating system and the user program.
V) Communication: These system calls are useful for interprocess communication. They also deal with creating and deleting a communication connection.