Lab Manual 21bce11136
Lab Manual 21bce11136
(UNIX, LINUX,
WINDOWSXP, WINDOWS7/8)
1. UNIX:
2. Linux:
3. Windows XP:
Software Requirements: Windows XP comes with its own software suite, including
system utilities, drivers, and optional components. It's compatible with a wide range
of applications designed for the Windows platform.
4. Windows 7/8:
Software Requirements: Windows 7 and 8 come with their own software suite and
are compatible with a wide range of applications designed for the Windows
platform. They also include additional features and enhancements over Windows
XP.
1. fork():
Creates a new process by duplicating the calling process. The new process is called
the child process, and the original process is the parent process.
#include <stdio.h>
#include <unistd.h>
int main() {
pid_t pid;
pid = fork();
if (pid < 0) {
// Error occurred
return 1;
} else if (pid == 0) {
// Child process
} else {
// Parent process
return 0;
2. exec():
Replaces the current process image with a new process image. There are several
variants of the exec() system call, such as execve(), execl(), execv(), etc., each taking
different arguments and providing different ways to execute a new program.
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int main() {
// Executing ls command
perror("exec");
return 1;
3. wait():
Suspends the execution of the calling process until one of its child processes
terminates. It allows the parent process to wait for the completion of the child
process.
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
int main() {
pid_t pid;
pid = fork();
if (pid < 0) {
// Error occurred
perror("Fork failed");
exit(EXIT_FAILURE);
} else if (pid == 0) {
// Child process
exit(EXIT_SUCCESS);
} else {
// Parent process
int status;
if (WIFEXITED(status)) {
} else {
exit(EXIT_SUCCESS);
4. waitpid():
Similar to wait(), but it allows the parent process to wait for a specific child process
to terminate, specified by its process ID (PID).
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
int main() {
int status;
pid = fork();
if (pid < 0) {
// Error occurred
perror("Fork failed");
exit(EXIT_FAILURE);
} else if (pid == 0) {
// Child process
exit(EXIT_SUCCESS);
} else {
// Parent process
if (child_pid == -1) {
perror("waitpid");
exit(EXIT_FAILURE);
if (WIFEXITED(status)) {
printf("Child process with PID %d exited with status: %d\n", child_pid,
WEXITSTATUS(status));
} else {
exit(EXIT_SUCCESS);
5. exit():
Terminates the calling process and returns an exit status to the parent process.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main() {
exit(0);
return 0;
6. getpid():
#include <stdio.h>
#include <unistd.h>
int main() {
// Get the process ID of the current process
return 0;
7. getppid():
#include <stdio.h>
#include <unistd.h>
int main() {
return 0;
}
8. kill():
Sends a signal to a process or a group of processes. Signals can be used for various
purposes, such as terminating a process (SIGKILL) or requesting it to terminate
gracefully (SIGTERM).
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
int main() {
if (result == 0) {
} else {
perror("kill");
exit(EXIT_FAILURE);
return 0;
9. signal():
Sets a signal handler for a specific signal. Signal handlers define how a process
should react when it receives a particular signal.
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
exit(EXIT_SUCCESS);
int main() {
signal(SIGINT, sigint_handler);
while (1) {
return 0;
10. nice():
Changes the priority of a process. It allows a process to voluntarily lower its priority
to give more CPU time to other processes.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main() {
int priority;
priority = nice(0);
if (priority == -1) {
perror("nice");
exit(EXIT_FAILURE);
if (new_priority == -1) {
perror("nice");
exit(EXIT_FAILURE);
return 0;
1. open():
Opens or creates a file and returns a file descriptor for further operations.
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
int main() {
int fd;
fd = open("example.txt", O_RDONLY);
if (fd == -1) {
perror("open");
exit(EXIT_FAILURE);
if (close(fd) == -1) {
perror("close");
exit(EXIT_FAILURE);
return 0;
2. close():
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
int main() {
int fd;
// Open a file in read-only mode
fd = open("example.txt", O_RDONLY);
if (fd == -1) {
perror("open");
exit(EXIT_FAILURE);
if (close(fd) == -1) {
perror("close");
exit(EXIT_FAILURE);
return 0;
3. read():
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
int main() {
int fd;
ssize_t bytes_read;
fd = open("example.txt", O_RDONLY);
if (fd == -1) {
perror("open");
exit(EXIT_FAILURE);
if (bytes_read == -1) {
perror("read");
exit(EXIT_FAILURE);
buffer[bytes_read] = '\0';
if (close(fd) == -1) {
perror("close");
exit(EXIT_FAILURE);
}
printf("File closed successfully\n");
return 0;
4. write():
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
int main() {
int fd;
ssize_t bytes_written;
if (fd == -1) {
perror("open");
exit(EXIT_FAILURE);
if (bytes_written == -1) {
perror("write");
exit(EXIT_FAILURE);
if (close(fd) == -1) {
perror("close");
exit(EXIT_FAILURE);
return 0;
5. lseek():
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
int main() {
int fd;
off_t offset;
fd = open("example.txt", O_RDWR);
if (fd == -1) {
perror("open");
exit(EXIT_FAILURE);
if (offset == -1) {
perror("lseek");
exit(EXIT_FAILURE);
if (close(fd) == -1) {
perror("close");
exit(EXIT_FAILURE);
return 0;
6. unlink():
Deletes a name from the file system. If that name was the last link to the file and no
processes have it open, the file is deleted.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main() {
if (unlink(filename) == -1) {
perror("unlink");
exit(EXIT_FAILURE);
return 0;
7. rename():
#include <stdio.h>
#include <stdlib.h>
int main() {
perror("rename");
exit(EXIT_FAILURE);
return 0;
}
8. mkdir():
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
int main() {
perror("mkdir");
exit(EXIT_FAILURE);
return 0;
9. rmdir():
Deletes a directory.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main() {
if (rmdir(dirname) == -1) {
perror("rmdir");
exit(EXIT_FAILURE);
return 0;
Retrieves information about a file (e.g., file size, permissions, modification time).
Syntax: int stat(const char *pathname, struct stat *buf); and int fstat(int fd, struct
stat *buf);
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
int main() {
perror("stat");
exit(EXIT_FAILURE);
}
printf("Information about file '%s':\n", filename);
if (fd == -1) {
perror("open");
exit(EXIT_FAILURE);
perror("fstat");
exit(EXIT_FAILURE);
if (close(fd) == -1) {
perror("close");
exit(EXIT_FAILURE);
return 0;
}
11. chmod():
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
int main() {
perror("chmod");
exit(EXIT_FAILURE);
return 0;
12. chown():
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main() {
const char *filename = "example.txt";
perror("chown");
exit(EXIT_FAILURE);
return 0;
1. open():
Opens or creates a file and returns a file descriptor for further operations.
2. close():
3. read():
4. write():
5. lseek():
Syntax: int dup(int oldfd); and int dup2(int oldfd, int newfd);
For dup()
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
int main() {
fd = open("example.txt", O_RDONLY);
if (fd == -1) {
perror("open");
exit(EXIT_FAILURE);
new_fd = dup(fd);
if (new_fd == -1) {
perror("dup");
exit(EXIT_FAILURE);
if (close(fd) == -1) {
perror("close");
exit(EXIT_FAILURE);
if (close(new_fd) == -1) {
perror("close");
exit(EXIT_FAILURE);
return 0;
For dup2()
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
int main() {
fd = open("example.txt", O_RDONLY);
if (fd == -1) {
perror("open");
exit(EXIT_FAILURE);
new_fd = dup2(fd, 100); // Duplicate to a specific file descriptor (100 in this case)
if (new_fd == -1) {
perror("dup2");
exit(EXIT_FAILURE);
if (close(fd) == -1) {
perror("close");
exit(EXIT_FAILURE);
return 0;
7. pipe():
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main() {
int pipefd[2];
char buffer[256];
ssize_t bytes_read;
// Create a pipe
if (pipe(pipefd) == -1) {
perror("pipe");
exit(EXIT_FAILURE);
if (pid == -1) {
perror("fork");
exit(EXIT_FAILURE);
close(pipefd[1]);
if (bytes_read == -1) {
perror("read");
exit(EXIT_FAILURE);
close(pipefd[0]);
exit(EXIT_SUCCESS);
close(pipefd[0]);
// Write to the pipe
perror("write");
exit(EXIT_FAILURE);
close(pipefd[1]);
return 0;
8. ioctl():
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <errno.h>
int main() {
int fd;
fd = open(device, O_RDWR);
if (fd == -1) {
perror("open");
exit(EXIT_FAILURE);
perror("ioctl");
close(fd);
exit(EXIT_FAILURE);
if (close(fd) == -1) {
perror("close");
exit(EXIT_FAILURE);
return 0;
9. fcntl():
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
int main() {
fd = open("example.txt", O_RDONLY);
if (fd == -1) {
perror("open");
exit(EXIT_FAILURE);
if (new_fd == -1) {
perror("fcntl");
exit(EXIT_FAILURE);
if (close(fd) == -1) {
perror("close");
exit(EXIT_FAILURE);
if (close(new_fd) == -1) {
perror("close");
exit(EXIT_FAILURE);
}
return 0;
Syntax: int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
struct timeval *timeout); for select(), int poll(struct pollfd *fds, nfds_t nfds, int
timeout); for poll(), and int epoll_wait(int epfd, struct epoll_event *events, int
maxevents, int timeout); for epoll().
For select()
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/select.h>
int main() {
fd_set read_fds;
// ...
while (1) {
FD_ZERO(&read_fds);
max_fd = -1;
FD_SET(client_socket[i], &read_fds);
max_fd = client_socket[i];
// Set timeout
timeout.tv_sec = 5;
timeout.tv_usec = 0;
// Call select
if (activity < 0) {
perror("select");
exit(EXIT_FAILURE);
if (activity == 0) {
printf("Timeout occurred\n");
continue;
if (FD_ISSET(client_socket[i], &read_fds)) {
if (bytes_read == -1) {
perror("read");
} else if (bytes_read == 0) {
close(client_socket[i]);
client_socket[i] = 0;
} else {
// Process data
return 0;
For poll()
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <poll.h>
int main() {
// ...
while (1) {
// Set up file descriptors for polling
fds[i].events = POLLIN; // Set events to poll for (e.g., POLLIN for input)
// Call poll
if (activity == -1) {
perror("poll");
exit(EXIT_FAILURE);
} else if (activity == 0) {
printf("Timeout occurred\n");
continue;
if (bytes_read == -1) {
perror("read");
} else if (bytes_read == 0) {
// Handle disconnection
} else {
// Process data
}
return 0;
For epoll()
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/epoll.h>
int main() {
// ...
while (1) {
if (num_events == -1) {
perror("epoll_wait");
exit(EXIT_FAILURE);
} else if (num_events == 0) {
printf("Timeout occurred\n");
continue;
}
// Handle events
// Read data from the file descriptor associated with the event
if (bytes_read == -1) {
perror("read");
} else if (bytes_read == 0) {
// Handle disconnection
} else {
// Process data
return 0;
}
Lab Assessment – 2
FCFS - First Come First Serve
#include <stdio.h>
#include <stdlib.h>
#define MAX_PROCESSES 10
// Process structure
typedef struct {
} Process;
processes[0].waiting_time = 0;
processes[0].turnaround_time = processes[0].burst_time;
processes[i].arrival_time, processes[i].waiting_time,
processes[i].turnaround_time);
}
int main() {
scanf("%d", &n);
processes[i].id = i + 1;
scanf("%d", &processes[i].burst_time);
scanf("%d", &processes[i].arrival_time);
calculate_fcfs_times(processes, n);
printf("\nFCFS Scheduling:\n");
display_fcfs_processes(processes, n);
return 0;
Input
Output
#include <stdlib.h>
#define MAX_PROCESSES 10
// Process structure
typedef struct {
} Process;
// Swap processes
processes[j + 1] = temp;
}
}
processes[0].waiting_time = 0;
processes[0].turnaround_time = processes[0].burst_time;
processes[i].arrival_time, processes[i].waiting_time,
processes[i].turnaround_time);
int main() {
scanf("%d", &n);
processes[i].id = i + 1;
scanf("%d", &processes[i].arrival_time);
sort_by_burst_time(processes, n);
calculate_sjf_times(processes, n);
printf("\nSJF Scheduling:\n");
display_sjf_processes(processes, n);
return 0;
Input
Output
Priority Scheduling
#include <stdio.h>
#include <stdlib.h>
#define MAX_PROCESSES 10
Input
Output
Multi-level Queue
#include <stdio.h>
#include <stdlib.h>
#define MAX_PROCESSES 10
#define NUM_QUEUES 3
// Process structure
typedef struct {
} Process;
processes[i].turnaround_time);
int main() {
// Initialize queues
queues[i][j] = NULL;
processes[i].id = i + 1;
scanf("%d", &processes[i].burst_time);
scanf("%d", &processes[i].priority);
scanf("%d", &processes[i].arrival_time);
queues[processes[i].priority][rear[processes[i].priority]++] = &processes[i];
queues[i][j]->turnaround_time = queues[i][j]->burst_time;
total_turnaround_time += queues[i][j]->turnaround_time;
if (j > 0) {
total_waiting_time += queues[i][j]->waiting_time;
} else {
queues[i][j]->waiting_time = 0;
}
// Calculate average waiting time and average turnaround time
display_processes(processes, n);
return 0;
Input
Output
LAB – 3
int main() {
// Initialize disk with free space
for (int i = 0; i < DISK_SIZE; ++i) {
disk[i] = '\0';
}
// Example usage
printf("Initial Disk Status:\n");
printDiskStatus();
allocate('A', 5);
allocate('B', 3);
printDiskStatus();
deallocate('A');
printDiskStatus();
allocate('C', 7);
printDiskStatus();
return 0;
}
(b) Linked –list (using linked list)
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
DiskBlock* head = NULL; // Head of the linked list representing the disk
int freeSpace = 0; // Tracks the available free space
int main() {
// Initialize free space
freeSpace = 100;
// Example usage
printf("Initial Disk Status:\n");
printDiskStatus();
allocate('A', 5);
allocate('B', 3);
printDiskStatus();
deallocate('A');
printDiskStatus();
allocate('C', 7);
printDiskStatus();
return 0;
}
// Example usage
printf("Initial Disk Status:\n");
printDiskStatus();
allocate('A', 5);
allocate('B', 3);
printDiskStatus();
deallocate('A');
printDiskStatus();
allocate('C', 7);
printDiskStatus();
return 0;
}
LAB – 4
#include <stdio.h>
// Function prototypes
void worstFit(struct Block freeBlocks[], int n, int processes[], int m);
void bestFit(struct Block freeBlocks[], int n, int processes[], int m);
void firstFit(struct Block freeBlocks[], int n, int processes[], int m);
int main() {
// Sample data
struct Block freeBlocks[MAX_BLOCKS] = {{1, 100, 0}, {2, 200, 0}, {3, 50, 0}};
int processes[] = {20, 70, 30, 60};
return 0;
}
#include <stdio.h>
// Function prototypes
void calculateFragmentation(struct Block freeBlocks[], int n);
int main() {
// Sample data
struct Block freeBlocks[MAX_BLOCKS] = {{1, 100, 0}, {2, 200, 0}, {3, 50, 0}};
int n = sizeof(freeBlocks) / sizeof(freeBlocks[0]);
calculateFragmentation(freeBlocks, n);
return 0;
}
Implementation of Compaction for the continually changing memory layout and calculate total
movement of data.
#include <stdio.h>
struct Block {
int id;
int size;
int allocated;
};
// Function prototypes
int main() {
// Sample data
struct Block freeBlocks[MAX_BLOCKS] = {{1, 100, 1}, {2, 200, 0}, {3, 50, 1}};
printf("Before Compaction:\n");
printMemoryLayout(freeBlocks, n);
int totalMovement = 0;
compactMemory(freeBlocks, n, &totalMovement);
printf("\nAfter Compaction:\n");
printMemoryLayout(freeBlocks, n);
return 0;
int currentPos = 0;
if (freeBlocks[i].allocated) {
freeBlocks[i].id = currentPos++;
printf("Block ID\tSize\tAllocated\n");
}
LAB – 7
#include <stdio.h>
#include <stdbool.h>
struct Node {
int id;
bool visited;
bool allocated;
};
struct Edge {
int from;
int to;
};
// Function prototypes
void addEdge(struct Edge edges[], int *numEdges, int from, int to);
void printGraph(struct Node nodes[], struct Edge edges[], int n, int numEdges);
bool isCycleUtil(struct Node nodes[], struct Edge edges[], int n, int u);
int main() {
// Initialize nodes
initializeGraph(nodes, numNodes);
// Add edges
} else {
return 0;
nodes[i].id = i;
nodes[i].visited = false;
nodes[i].allocated = false;
void addEdge(struct Edge edges[], int *numEdges, int from, int to) {
edges[*numEdges].from = from;
edges[*numEdges].to = to;
(*numEdges)++;
void printGraph(struct Node nodes[], struct Edge edges[], int n, int numEdges) {
if (!nodes[u].visited) {
nodes[u].visited = true;
nodes[u].allocated = true;
if (edges[i].from == u) {
return true;
} else if (nodes[edges[i].to].allocated) {
return true;
}
nodes[u].allocated = false;
return false;
return true;
return false;
}
LAB – 8
Bankers Algorithm
#include <stdio.h>
#include <stdbool.h>
// Function prototypes
int main() {
int available[MAX_RESOURCES];
int max[MAX_PROCESSES][MAX_RESOURCES];
int allocation[MAX_PROCESSES][MAX_RESOURCES];
int need[MAX_PROCESSES][MAX_RESOURCES];
int processes[MAX_PROCESSES];
scanf("%d", &numProcesses);
scanf("%d", &numResources);
scanf("%d", &max[i][j]);
scanf("%d", &allocation[i][j]);
printSafeSequence(processes, numProcesses);
} else {
}
return 0;
bool finish[numProcesses];
int work[MAX_RESOURCES];
int safeSequence[numProcesses];
int count = 0;
finish[i] = false;
work[i] = available[i];
if (!finish[i]) {
canAllocate = false;
break;
if (canAllocate) {
work[j] += allocation[i][j];
safeSequence[count++] = i;
finish[i] = true;
found = true;
if (!found) {
break;
if (count != numProcesses) {
return false;
// Safe state
return true;
printf("\n");
}
LAB – 9
Wait Graph
Conversion of resource allocation graph (RAG) to wait-for-graph (WFG) for each type of method
used for storing graph.
#include <stdio.h>
#include <stdbool.h>
struct Node {
int id;
};
// Function prototypes
int main() {
rag[i] = NULL;
rag[0]->id = 1;
rag[0]->next = NULL;
rag[1]->next = NULL;
rag[2]->id = 0;
rag[2]->next = NULL;
// Number of processes
int numProcesses = 3;
current = current->next;
printf("\n");
bool wfgMatrix[MAX_NODES][MAX_NODES];
current = current->next;
printf("\n");
return 0;
wfg[i] = NULL;
if (i != j) {
if (current->id == i) {
newNode->id = j;
newNode->next = wfg[i];
wfg[i] = newNode;
break;
current = current->next;
if (i != j && rag[j][i]) {
wfg[i][j] = true;
} else {
wfg[i][j] = false;
}
LAB – 10
Implement the solution for Bounded Buffer (Producer-Consumer) problem using inter process
communication technique – Semaphores.
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <semaphore.h>
#define BUFFER_SIZE 5
pthread_mutex_t mutex;
int buffer[BUFFER_SIZE];
int in = 0, out = 0;
int item;
while (1) {
sem_wait(&empty);
pthread_mutex_lock(&mutex);
buffer[in] = item;
in = (in + 1) % BUFFER_SIZE;
pthread_mutex_unlock(&mutex);
sem_post(&full);
sleep(1);
}
void *consumer(void *arg) {
int item;
while (1) {
sem_wait(&full);
pthread_mutex_lock(&mutex);
item = buffer[out];
pthread_mutex_unlock(&mutex);
sem_post(&empty);
sleep(2);
int main() {
sem_init(&empty, 0, BUFFER_SIZE);
sem_init(&full, 0, 0);
pthread_mutex_init(&mutex, NULL);
pthread_join(producer_thread, NULL);
pthread_join(consumer_thread, NULL);
sem_destroy(&empty);
sem_destroy(&full);
pthread_mutex_destroy(&mutex);
return 0;
II. Implement the solution for Readers-Writers problem using inter process communication
technique – Semaphores.
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <semaphore.h>
int f;
f = *((int *)arg);
sem_wait(&mutex);
readcount++;
if (readcount == 1)
sem_wait(&writeblock);
sem_post(&mutex);
sleep(1);
sem_wait(&mutex);
readcount--;
if (readcount == 0)
sem_post(&writeblock);
sem_post(&mutex);
int f;
f = *((int *)arg);
sem_wait(&writeblock);
data++;
sleep(1);
sem_post(&writeblock);
int main() {
int i;
sem_init(&mutex, 0, 1);
sem_init(&writeblock, 0, 1);
pthread_join(wtid[i], NULL);
pthread_join(rtid[i], NULL);
return 0;
}
III. Implement the solution for Dining-Philosopher problem using inter process communication
technique – Semaphores.
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <semaphore.h>
#include <unistd.h>
#define N 5
#define THINKING 2
#define HUNGRY 1
#define EATING 0
int state[N];
sem_t mutex;
sem_t S[N];
state[phnum] = EATING;
sleep(2);
sem_post(&S[phnum]);
sem_wait(&mutex);
state[phnum] = HUNGRY;
test(phnum);
sem_post(&mutex);
sem_wait(&S[phnum]);
sleep(1);
sem_wait(&mutex);
state[phnum] = THINKING;
test(LEFT);
test(RIGHT);
sem_post(&mutex);
while (1) {
int *i = num;
sleep(1);
take_fork(*i);
sleep(0);
put_fork(*i);
int main() {
int i;
pthread_t thread_id[N];
sem_init(&mutex, 0, 1);
sem_init(&S[i], 0, 0);
pthread_join(thread_id[i], NULL);
}
LAB – 11
I. Write a program where parent process take average of the odd numbers and child
process will take the average of even numbers present in a given Aadhar number of a
person. Use FORK and JOIN construct.
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
int main() {
int numbers[] = {12, 23, 34, 45, 56, 67, 78, 89, 90, 101};
int size = sizeof(numbers) / sizeof(numbers[0]);
return 0;
}
II. II. Write a program where parent process finds additive primes and child process finds
circular prime for a given prime list array. Use FORK and JOIN construct.
#include <stdio.h>
#include <unistd.h>
#include <stdbool.h>
#include <sys/wait.h>
int main() {
int prime_list[] = {7, 11, 13, 17, 23, 29, 31, 37, 41, 47};
int size = sizeof(prime_list) / sizeof(prime_list[0]);
return 0;
}