Os 4 - Merged
Os 4 - Merged
2300321540020
AKSHAT GUPTA
2300321540020
AKSHAT GUPTA
2300321540020
ABES ENGINEERING COLLEGE [Department of CSE-Data Science]
Operating System Lab [BCS-451]
2nd Year||4th Semester||Section: A||Group:A1
Experiment – 2
#include <stdio.h>
#include <unistd.h>
<sys/wait.h>
int main() {
if (pid < 0) {
// Fork failed
perror("Fork failed");
return 1;
// Child process
printf("Child Process:\n");
} else {
// Parent process
printf("Parent Process:\n");
return 0;
Output
Child Process:
Parent Process:
#include <unistd.h>
int main() {
int fd;
if (fd < 0) {
return 1;
close(fd);
fd = open("sample.txt", O_RDONLY);
if (fd < 0) {
return 1;
close(fd);
return 0;
Output :
File content:
char buffer[100];
int n;
return 0;
Output (Example):
Enter some text: Hello System Calls!
Experiment – 3
Objective: Write a C program to simulate the First Come First Serve (FCFS)
non-preemptive CPU scheduling algorithm.
#include<stdio.h>
#include<conio.h>
void main() {
clrscr();
scanf("%d", &n);
scanf("%d", &bt[i]);
wt[0] = wtavg = 0;
AKSHAT GUPTA
2300321540020
ABES ENGINEERING COLLEGE [Department of CSE-Data Science]
Operating System Lab [BCS-451]
2nd Year||4th Semester||Section: A||Group:A1
for(i = 0; i < n; i++) {
getch();
AKSHAT GUPTA
2300321540020