Professional Documents
Culture Documents
IPC and Related System Calls
IPC and Related System Calls
Prepared by:
Shreeji Sheth
Technical Associate (Embedded)| eiTRA
l
l
l
l
Memory Based
l
l
Shared memory
Memory mapped files
System Calls
l
l
l
l
l
l
l
FIFO
int mkfifo(const char *pathname, mode_t mode);
Mknod
Open(),close(),unlink()
Read(), write()-4k max
Write operation is atomic
Opening FIFO for read or write blocks until other
process opens it for write or read
System Calls...
l
l
l
Pipe
Pipe()
Read(),write(),close()
System Calls...
l
l
Queue
Msgget(), msgctl(), msgsnd(), msgrcv(),
System Calls...
l
l
l
Signals
Signal.h
int kill(int pid, int signal); //where signal value
can be SIGHUP 1 /* hangup */ ;SIGINT 2 /*
interrupt */; SIGQUIT 3 /* quit */; SIGILL 4 /*
illegal instruction */; SIGABRT 6 /* used by
abort */; SIGKILL 9 /* hard kill */; SIGALRM
14 /* alarm clock */; SIGCONT 19 /* continue a
stopped process */; SIGCHLD 20 /* to parent
on child stop or exit */
System Calls...
Signals
int raise(int sig) equivalent to kill(getpid(), sig);
int sighold(int sig) -- adds sig to the calling
process's signal mask
int sigrelse(int sig) -- removes sig from the calling
process's signal mask
int sigignore(int sig) -- sets the disposition of sig to
SIG_IGN
int sigpause(int sig) -- removes sig from the
calling process's signal mask and suspends the
calling process until a signal is received
System calls...
l
l
l
l
l
Shared Memory
Shmget()
Ftok()
Shmat(),shmdt(),shmctl()
Shmat() returns pointer to the shared memory
segment
System Calls
l
l
Socket programming
Socket(),
bind(),connect(),listen(),accept(),recvfrom(),sen
dto()-for connection less,recv(),send()-for
connection oriented, close(),