operating system exercise threads, Exercises of Computer science

studing hard and do your best.good luck

Typology: Exercises

2018/2019

Uploaded on 09/29/2021

unknown user
unknown user 🇱🇰

4 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Operating System

Partial preview of the text

Download operating system exercise threads and more Exercises Computer science in PDF only on Docsity!

Operating System

Operating System Learning Objectives: In this lab, you will learn about Intercrosses communication with signals and pipes. ‘The Linux IPC (Inter-process communication) facilities provide a method for multiple processes to communicate with onc another. There are several methods of IPC available to Linux C programmers: Pipes Signals Message queues Semaphore sets Shared memory segments Sockets Pipes are known as the oldest communication mechanism under UNIX. To create a simple pipe with C, we make use of the pipe() system call. It takes a single argument, which is an array of two integers, and if successful, the array will contain two new file descriptors to be used for the pipeline. A pipc is created by calling the pipe () function in the following way. int fd[2}; if (pipe(fd) < 0) print{{*Error!\n"); ‘The pipe() function is invoked. This returns two valid file descriptors in the array given as the argument. The input of the first file descriptor (l[0]) is the output of the second file descriptor (fa{1). Exercise 01:Write the following program and execute to understand the concept of pipe. #include main() { int pipefd[2]; int i; char s[1000}; char *s2; if (pipe(pipefd) < 0) { perror("pipe’); exit(1); }