Your SlideShare is downloading. ×
0
Inter process communication
Inter process communication
Inter process communication
Inter process communication
Inter process communication
Inter process communication
Inter process communication
Inter process communication
Inter process communication
Inter process communication
Inter process communication
Inter process communication
Inter process communication
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Inter process communication

2,489

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,489
On Slideshare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
81
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Inter process communication
  • 2. Semaphore info
  • 3. Shared memory info
  • 4. Message queue info
  • 5. Pipes & named pipes
    Pipes are the classical method of interprocess communication.
    For example
    ls –l | more
    The 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 & named pipes
    # mkfifo pathname
    Example
    # mkfifo hello
    # ls –l hello
    prw-r- -r- – 1 temp users 0 Aug 28 10.45 hello |
  • 7. Pipes & named pipes
    there 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 & named pipes
    structpipe_inode_info
    {
    wait_queue_head_t wait; //wait queue
    char * base; //address of the FIFO buffer
    unsigned int readers; //no of processes reading at this moment
    unsigned int writers; //no of processes writing at this moment
    unsigned intwaiting_readers; //no of blocked process reading at this moment
    unsigned intwaiting_writers; //no of blocked processes writing at this moment
    unsigned intr_counter; //no of read processes that have opened
    unsigned intw_counter; //no of write processes that have opened
    };
  • 9. Open a fifo
  • 10. ptrace
    Ptrace is a system call provided in unix for one process to take control of another process to debug errors or bugs in the system
    The 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 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 sockets
    Represented by a kernel data structure socket
    Socket 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 Unix domain sockets
    long sys_socket(int family, int type, int protocol);// creates a socket file descriptor
    long sys_connect(intfd, structsockaddr * uservaddr, intaddrlen); //bind the socket to the unix domain address with specified length
    long 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 on
    long sys_getsockname(intfd, structsockaddr *usockaddr, int *usockaddr_len); //the address bound to the socket is returned.
  • 13. Sockets
    long sys_shutdown(intfd, int how); //to shutdown but status to be given that whether the sending and receiving still allowed
    sending and receiving from the sockets
    Messages can be sent either as a datagram or stream of bytes
    long 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)

×