Inter process communication
Semaphore info
Shared memory info
Message queue info
Pipes & named pipesPipes are the classical method of interprocess communication.For examplels –l | moreThe symbol | indicates a pipe and the shell in the above example runs the processes ls and more which are linked with a pipe. ls writes data to the pipe and more reads it.Named pipes otherwise called as the FIFO (First in First Out) is the other variant of pipe.
Pipes & named pipes# mkfifo pathnameExample# mkfifo hello# ls –l helloprw-r- -r- – 1 temp users 0 Aug 28 10.45 hello |
Pipes & named pipesthere are many similarities between the pipes and the FIFO, but the inode specification for the both are more or less the same.following is the inode specification for the pipe
Pipes & named pipesstructpipe_inode_info{wait_queue_head_t wait; //wait queuechar * base; //address of the FIFO bufferunsigned int readers; //no of processes reading at this momentunsigned int writers; //no of processes writing at this momentunsigned intwaiting_readers; //no of blocked process reading at this momentunsigned intwaiting_writers; //no of blocked processes writing at this momentunsigned intr_counter; //no of read processes that have openedunsigned intw_counter; //no of write processes that have opened};
Open a fifo
ptracePtrace is a system call provided in unix for one process to take control of another process to debug errors or bugs in the systemThe process under control can be run step by step and its memory can be read and modified.intsys_ptrace(long request, long pid, long addr, long data);the function processes various request defined in the parameter request and pid indicates the process id of the process to be controlled.Using the request PTRACE_TRACEME, a process can specify that its parent process controls iut via ptrace().
Sockets	Socket programming interfaces provides communication via a network as well as locally on a single computer. Example is INET daemon which waits for incoming network service requests and then call the appropriate service program using the socket file descriptor as standard input and output.Implementation of Unix domain socketsRepresented by a kernel data structure socketSocket specific functions like Socket(), setsockout()The functions are implemented with a single system call socketcall which calls all the necessary functions by reference to the first parameter. The file operation read(), write(), poll(), ioctl(), lseek(), close() are called directly
Sockets	Operations of Unix domain socketslong sys_socket(int family, int type, int protocol);// creates a socket file descriptorlong sys_connect(intfd, structsockaddr * uservaddr, intaddrlen); //bind the socket to the unix domain address with specified lengthlong sys_listen(intfd, int backlog);//checks whether any connections are being accepted at the server address.long sys_accept(intfd, structsockaddr *upeer_sockaddr, int *upeer_addrlen));//server informs the kernel that the connections are being accepted from now onlong sys_getsockname(intfd, structsockaddr *usockaddr, int *usockaddr_len); //the address bound to the socket is returned.
Sockets	long sys_shutdown(intfd, int how); //to shutdown but status to be given that whether the sending and receiving still allowedsending and receiving from the socketsMessages can be sent either as a datagram or stream of byteslong sys_send(intfd, void *buff, intlen, unsigned flags);long sys_sendmsg(intfd, structmsghdr *msg, unsigned int flags);long sys_recv(intfd, void *buff, intlen, unsigned flags);long sys_recvmsg(intfd, structmsghdr *msg, unsigned int flags)

Inter process communication

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
    Pipes & namedpipesPipes are the classical method of interprocess communication.For examplels –l | moreThe symbol | indicates a pipe and the shell in the above example runs the processes ls and more which are linked with a pipe. ls writes data to the pipe and more reads it.Named pipes otherwise called as the FIFO (First in First Out) is the other variant of pipe.
  • 6.
    Pipes & namedpipes# mkfifo pathnameExample# mkfifo hello# ls –l helloprw-r- -r- – 1 temp users 0 Aug 28 10.45 hello |
  • 7.
    Pipes & namedpipesthere are many similarities between the pipes and the FIFO, but the inode specification for the both are more or less the same.following is the inode specification for the pipe
  • 8.
    Pipes & namedpipesstructpipe_inode_info{wait_queue_head_t wait; //wait queuechar * base; //address of the FIFO bufferunsigned int readers; //no of processes reading at this momentunsigned int writers; //no of processes writing at this momentunsigned intwaiting_readers; //no of blocked process reading at this momentunsigned intwaiting_writers; //no of blocked processes writing at this momentunsigned intr_counter; //no of read processes that have openedunsigned intw_counter; //no of write processes that have opened};
  • 9.
  • 10.
    ptracePtrace is asystem call provided in unix for one process to take control of another process to debug errors or bugs in the systemThe process under control can be run step by step and its memory can be read and modified.intsys_ptrace(long request, long pid, long addr, long data);the function processes various request defined in the parameter request and pid indicates the process id of the process to be controlled.Using the request PTRACE_TRACEME, a process can specify that its parent process controls iut via ptrace().
  • 11.
    Sockets Socket programming interfacesprovides communication via a network as well as locally on a single computer. Example is INET daemon which waits for incoming network service requests and then call the appropriate service program using the socket file descriptor as standard input and output.Implementation of Unix domain socketsRepresented by a kernel data structure socketSocket specific functions like Socket(), setsockout()The functions are implemented with a single system call socketcall which calls all the necessary functions by reference to the first parameter. The file operation read(), write(), poll(), ioctl(), lseek(), close() are called directly
  • 12.
    Sockets Operations of Unixdomain socketslong sys_socket(int family, int type, int protocol);// creates a socket file descriptorlong sys_connect(intfd, structsockaddr * uservaddr, intaddrlen); //bind the socket to the unix domain address with specified lengthlong sys_listen(intfd, int backlog);//checks whether any connections are being accepted at the server address.long sys_accept(intfd, structsockaddr *upeer_sockaddr, int *upeer_addrlen));//server informs the kernel that the connections are being accepted from now onlong sys_getsockname(intfd, structsockaddr *usockaddr, int *usockaddr_len); //the address bound to the socket is returned.
  • 13.
    Sockets long sys_shutdown(intfd, inthow); //to shutdown but status to be given that whether the sending and receiving still allowedsending and receiving from the socketsMessages can be sent either as a datagram or stream of byteslong sys_send(intfd, void *buff, intlen, unsigned flags);long sys_sendmsg(intfd, structmsghdr *msg, unsigned int flags);long sys_recv(intfd, void *buff, intlen, unsigned flags);long sys_recvmsg(intfd, structmsghdr *msg, unsigned int flags)