Lab 4
Lab 4
CO-Mapping
CO1 CO2 CO3
Q1 √
Q2 √
Q3 √
Objectives: To understand the usability of system calls for various tasks, and work with the system
calls to communicate with the system resources.
Theory: The interface between a process and an operating system is provided by system calls. In
general, system calls are available as assembly language instructions. They are also included in the
manuals used by assembly-level programmers. System calls are usually made when a process in user
mode requires access to a resource. Then it requests the kernel to provide the resource via a system
calls.
Q1. Write a C/C++code to demonstrate the working of fork() system call by creating a child
process.
Test Cases1:
------------------------------------------------------------------------
School of Computer Science Engineering and Technology
Q2. Write a program in C/C++ that utilizes the fork() system call to demonstrate the
duplication of processes. Implement a for loop to print natural numbers from S to T. Upon
constructing a fork(), observe that the numbers are displayed twice due to the creation of a
duplicate copy of the process.
Test Cases1:
Input: 0
10
Q3. Write a C program that uses the fork system call to create a child process. The parent
process should print its own process ID, while the child process should print its own process
ID. If there is an error in the process creation, the program should print an error message
and exit with a failure status.