write()/read() system call
write() system call is used to write to a file descriptor. In other words write() can be used to write to any file (all hardware are also referred as file
write() system call is used to write to a file descriptor. In other words write() can be used to write to any file (all hardware are also referred as file
Program for IPC using named pipes (mkfifo()) The third method for IPC is using mkfifo() function. mkfifo() creates a named pipe which can be used exactly like a file. So, if you know how to read/write in a file this is a convenient method for IPC Syntax: #include<sys/types.h>#include<sys/stat.h>int mkfifo(const char *pathname, mode_t mode); mkfifo() makes …
The second method for IPC is using the pipe() function. Before writing a program for IPC using pipe() function let us first understand its working. Syntax: #include<unistd.h>int pipe(int pipefd[2]); pipe() function creates a unidirectional pipe for IPC. On success it return two file descriptors pipefd[0] and pipefd[1]. pipefd[0] is the reading end of the pipe. …
Program for IPC using pipes
int shared=1; //shared variable
sem_t s; //semaphore variable
int main()
{
sem_init(&s,0,1)
An orphan process is a process whose parent has finished. Suppose P1 and P2 are two process such that P1 is the parent process and P2
There is a family of function which can be used for replacing the current process with a new process. They differ in the number of arguments and the way they start a new process. The various functions are execl, execlp, execle, execv and execvp. In this post we will write a Program to replace process image using execl( …
/* Program for process synchronization using locks Program create two threads: one to increment the value of a shared variable and second to decrement the value of shared variable. Both the threads make use of locks so that only one of the threads is executing in its critical section */ #include<pthread.h>#include<stdio.h>#include<unistd.h>void *fun1();void *fun2(); int shared=1; …
Program for Process Synchronization using mutex locks Read More »
Program to create two threads: one to increment the value of a shared variable and second to decrement the value of shared variable.
Program to create threads using C in Linux