SlideShare a Scribd company logo
1 of 87
Download to read offline
Processes (Part III)
Amir H. Payberah
amir@sics.se
Amirkabir University of Technology
(Tehran Polytechnic)
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 1 / 50
Inter-Process Communication
(IPC)
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 2 / 50
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 3 / 50
Socket
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 4 / 50
Letā€™s First Review The Basic
Concepts of TCP/IP
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 5 / 50
Internetworking
An internetwork (internet (with a lowercase i)) is a network of com-
puter networks.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 6 / 50
Internetworking
An internetwork (internet (with a lowercase i)) is a network of com-
puter networks.
Subnetwork refers to one of the networks composing an internet.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 6 / 50
Internetworking
An internetwork (internet (with a lowercase i)) is a network of com-
puter networks.
Subnetwork refers to one of the networks composing an internet.
An internet aims to hide the details of diļ¬€erent physical networks,
to present a uniļ¬ed network architecture.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 6 / 50
The Internet
TCP/IP has become the dominant protocol for the internetworking.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 7 / 50
The Internet
TCP/IP has become the dominant protocol for the internetworking.
The Internet (with an uppercase I) refers to the TCP/IP internet
that connects millions of computers globally.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 7 / 50
The Internet
TCP/IP has become the dominant protocol for the internetworking.
The Internet (with an uppercase I) refers to the TCP/IP internet
that connects millions of computers globally.
The ļ¬rst widespread implementation of TCP/IP appeared with
4.2BSD in 1983.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 7 / 50
Networking Protocols and Layers
A networking protocol is a set of rules deļ¬ning how information is
to be transmitted across a network.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 8 / 50
Networking Protocols and Layers
A networking protocol is a set of rules deļ¬ning how information is
to be transmitted across a network.
Networking protocols are generally organized as a series of layers.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 8 / 50
Networking Protocols and Layers
A networking protocol is a set of rules deļ¬ning how information is
to be transmitted across a network.
Networking protocols are generally organized as a series of layers.
Each layer building on the layer below it to add features that are
made available to higher layers.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 8 / 50
Networking Protocols and Layers
A networking protocol is a set of rules deļ¬ning how information is
to be transmitted across a network.
Networking protocols are generally organized as a series of layers.
Each layer building on the layer below it to add features that are
made available to higher layers.
Transparency: each protocol layer shields higher layers from the
operation and complexity of lower layers.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 8 / 50
TCP/IP Protocol Suite
The TCP/IP protocol suite is a layered networking protocol.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 9 / 50
TCP/IP Protocol Layers
Data-Link layer
Network layer (IP)
Transport layer (TCP, UDP)
Application
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 10 / 50
Encapsulation
Encapsulation: the information passed from a higher layer to a lower
layer is treated as opaque data by the lower layer.
ā€¢ The lower layer does not interpret information from the upper layer.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 11 / 50
Encapsulation
Encapsulation: the information passed from a higher layer to a lower
layer is treated as opaque data by the lower layer.
ā€¢ The lower layer does not interpret information from the upper layer.
When data is passed up from a lower layer to a higher layer, a
converse unpacking process takes place.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 11 / 50
Data-Link Layer (1/3)
It is concerned with transferring data across a physical link in a
network.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 12 / 50
Data-Link Layer (1/3)
It is concerned with transferring data across a physical link in a
network.
It consists of the device driver and the hardware interface (network
card) to the underlying physical medium, e.g., ļ¬ber-optic cable.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 12 / 50
Data-Link Layer (2/3)
The data-link layer encapsulates datagrams from the network layer
into units, called frames.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 13 / 50
Data-Link Layer (2/3)
The data-link layer encapsulates datagrams from the network layer
into units, called frames.
It also adds each frame a header containing the destination address
and frame size.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 13 / 50
Data-Link Layer (2/3)
The data-link layer encapsulates datagrams from the network layer
into units, called frames.
It also adds each frame a header containing the destination address
and frame size.
The data-link layer transmits the frames across the physical link and
handles acknowledgements from the receiver.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 13 / 50
Data-Link Layer (3/3)
From an application-programming point of view, we can generally
ignore the data-link layer, since all communication details are han-
dled in the driver and hardware.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 14 / 50
Data-Link Layer (3/3)
From an application-programming point of view, we can generally
ignore the data-link layer, since all communication details are han-
dled in the driver and hardware.
Maximum Transmission Unit (MTU): the upper limit that the layer
places on the size of a frame.
ā€¢ data-link layers have diļ¬€erent MTUs.
netstat -i
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 14 / 50
Network Layer (1/4)
It is concerned with delivering data from the source host to the
destination host.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 15 / 50
Network Layer (1/4)
It is concerned with delivering data from the source host to the
destination host.
It tasks include:
ā€¢ Breaking data into fragments small enough for transmission via the
data-link layer.
ā€¢ Routing data across the internet.
ā€¢ Providing services to the transport layer.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 15 / 50
Network Layer (1/4)
It is concerned with delivering data from the source host to the
destination host.
It tasks include:
ā€¢ Breaking data into fragments small enough for transmission via the
data-link layer.
ā€¢ Routing data across the internet.
ā€¢ Providing services to the transport layer.
In the TCP/IP protocol suite, the principal protocol in the network
layer is IP.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 15 / 50
Network Layer (2/4)
IP transmits data in the form of packets.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 16 / 50
Network Layer (2/4)
IP transmits data in the form of packets.
Each packet sent between two hosts travels independently across
the network.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 16 / 50
Network Layer (2/4)
IP transmits data in the form of packets.
Each packet sent between two hosts travels independently across
the network.
An IP packet includes a header that contains the address of the
source and target hosts.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 16 / 50
Network Layer (3/4)
IP is a connectionless protocol: it does not provide a virtual circuit
connecting two hosts.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 17 / 50
Network Layer (3/4)
IP is a connectionless protocol: it does not provide a virtual circuit
connecting two hosts.
IP is an unreliable protocol: it makes a best eļ¬€ort to transmit data-
grams from the sender to the receiver, but it does not guarantee:
ā€¢ that packets will arrive in the order they were transmitted,
ā€¢ that they will not be duplicated,
ā€¢ that they will arrive at all.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 17 / 50
Network Layer (4/4)
An IP address consists of two parts:
ā€¢ Network ID: speciļ¬es the network on which a host resides.
ā€¢ Host ID: identiļ¬es the host within that network.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 18 / 50
Network Layer (4/4)
An IP address consists of two parts:
ā€¢ Network ID: speciļ¬es the network on which a host resides.
ā€¢ Host ID: identiļ¬es the host within that network.
An IPv4 address consists of 32 bits: 204.152.189.0/24
ā€¢ loopback 127.0.0.1 refers to system on which process is running.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 18 / 50
Network Layer (4/4)
An IP address consists of two parts:
ā€¢ Network ID: speciļ¬es the network on which a host resides.
ā€¢ Host ID: identiļ¬es the host within that network.
An IPv4 address consists of 32 bits: 204.152.189.0/24
ā€¢ loopback 127.0.0.1 refers to system on which process is running.
Network mask: a sequence of 1s in the leftmost bits, followed by a
sequence of 0s
ā€¢ The 1s indicate which part of the address contains the assigned
network ID.
ā€¢ The 0s indicate which part of the address is available to assign as
host IDs.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 18 / 50
Transport Layer (1/5)
Transport protocol provides an end-to-end communication service
to applications residing on diļ¬€erent hosts.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 19 / 50
Transport Layer (1/5)
Transport protocol provides an end-to-end communication service
to applications residing on diļ¬€erent hosts.
Two widely used transport-layer protocols in the TCP/IP suite:
ā€¢ User Datagram Protocol (UDP): the protocol used for datagram
sockets.
ā€¢ Transmission Control Protocol (TCP): the protocol used for stream
sockets.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 19 / 50
Transport Layer (2/5)
Port: a method of diļ¬€erentiating the applications on a host.
ā€¢ 16-bit number
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 20 / 50
Transport Layer (2/5)
Port: a method of diļ¬€erentiating the applications on a host.
ā€¢ 16-bit number
ā€¢ All ports below 1024 are well known, used for standard services,
e.g., http: 80, ssh: 22.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 20 / 50
Transport Layer (2/5)
Port: a method of diļ¬€erentiating the applications on a host.
ā€¢ 16-bit number
ā€¢ All ports below 1024 are well known, used for standard services,
e.g., http: 80, ssh: 22.
ā€¢ Shown as 192.168.1.1:8080.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 20 / 50
Transport Layer (3/5)
UDP, like IP, is connectionless and unreliable.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 21 / 50
Transport Layer (3/5)
UDP, like IP, is connectionless and unreliable.
If an application layered on top of UDP requires reliability, then this
must be implemented within the application.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 21 / 50
Transport Layer (3/5)
UDP, like IP, is connectionless and unreliable.
If an application layered on top of UDP requires reliability, then this
must be implemented within the application.
UDP adds just two features to IP:
ā€¢ Port number
ā€¢ Data checksum to allow the detection of errors in the transmitted
data.
[http://www.tamos.net/āˆ¼rhay/overhead/ip-packet-overhead.htm]
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 21 / 50
Transport Layer (4/5)
TCP provides a reliable, connection-oriented, bidirectional, byte-
stream communication channel between two endpoints.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 22 / 50
Transport Layer (4/5)
TCP provides a reliable, connection-oriented, bidirectional, byte-
stream communication channel between two endpoints.
Before communication can commence, TCP establishes a commu-
nication channel between the two endpoints.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 22 / 50
Transport Layer (5/5)
In TCP, data is broken into segments: each is transmitted in a single
IP packet.
[http://www.tamos.net/āˆ¼rhay/overhead/ip-packet-overhead.htm]
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 23 / 50
Transport Layer (5/5)
In TCP, data is broken into segments: each is transmitted in a single
IP packet.
When a destination receives a TCP segment, it sends an ack. to
the sender, informing weather it received the segment correctly or
not.
[http://www.tamos.net/āˆ¼rhay/overhead/ip-packet-overhead.htm]
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 23 / 50
Transport Layer (5/5)
In TCP, data is broken into segments: each is transmitted in a single
IP packet.
When a destination receives a TCP segment, it sends an ack. to
the sender, informing weather it received the segment correctly or
not.
Other features of TCP:
ā€¢ Sequencing
ā€¢ Flow control
ā€¢ Congestion control
[http://www.tamos.net/āˆ¼rhay/overhead/ip-packet-overhead.htm]
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 23 / 50
OK, Letā€™s Back to Socket
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 24 / 50
Socket
A socket is deļ¬ned as an endpoint for communication.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 25 / 50
Socket
A socket is deļ¬ned as an endpoint for communication.
A typical client-server scenario:
ā€¢ Each process creates a socket: both processes require one.
ā€¢ The server binds its socket to a well-known address (name) so that
clients can locate it.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 25 / 50
Creating a Socket
socket() creates a new socket.
#include <sys/socket.h>
int socket(int domain, int type, int protocol);
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 26 / 50
Socket Domains
The UNIX domain (AF UNIX)
ā€¢ Communication between processes on the same host (within the
kernel).
ā€¢ Address format: path name.
int socket(int domain, int type, int protocol);
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 27 / 50
Socket Domains
The UNIX domain (AF UNIX)
ā€¢ Communication between processes on the same host (within the
kernel).
ā€¢ Address format: path name.
The IPV4 domain (AF INET)
ā€¢ Communication between processes running on hosts connected via
an IPv4 network.
ā€¢ Address format: 32-bit IPv4 address + 16-bit port number.
int socket(int domain, int type, int protocol);
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 27 / 50
Socket Types
Stream sockets (SOCK STREAM)
ā€¢ It provides a reliable, bidirectional, byte-stream communication
channel.
ā€¢ Called connection-oriented.
int socket(int domain, int type, int protocol);
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 28 / 50
Socket Types
Stream sockets (SOCK STREAM)
ā€¢ It provides a reliable, bidirectional, byte-stream communication
channel.
ā€¢ Called connection-oriented.
Datagram sockets (SOCK DGRAM)
ā€¢ Allow data to be exchanged in the form of messages called
datagrams.
ā€¢ Called connectionless.
int socket(int domain, int type, int protocol);
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 28 / 50
Binding a Socket to an Address
bind() binds a socket to an address.
#include <sys/socket.h>
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 29 / 50
Listening for Incoming Connections
listen() marks the stream socket passive.
The socket will subsequently be used to accept connections from
other (active) sockets.
#include <sys/socket.h>
int listen(int sockfd, int backlog);
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 30 / 50
Accepting a Connection
accept() accepts an incoming connection on the listening stream
socket.
If there are no pending connections when accept() is called, the
call blocks until a connection request arrives.
#include <sys/socket.h>
int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 31 / 50
Connecting to a Peer Socket
connect() connects the active socket to the listening socket whose
address is speciļ¬ed by addr and addrlen.
#include <sys/socket.h>
int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 32 / 50
Stream Sockets
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 33 / 50
Producer-Consumer vi Stream Socket (1/2)
Producer (Server)
int sockfd, connfd;
struct sockaddr_in serv_addr, cli_addr;
socklen_t cli_len;
char buffer[256];
bzero(&serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
serv_addr.sin_port = htons(32000);
sockfd = socket(AF_INET, SOCK_STREAM, 0);
bind(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
listen(sockfd, 5);
cli_len = sizeof(cli_addr);
connfd = accept(sockfd, (struct sockaddr *)&cli_addr, &cli_len);
read(connfd, buffer, 255);
write(connfd, "I got your message", 18);
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 34 / 50
Producer-Consumer vi Stream Socket (2/2)
Consumer (Client)
int sockfd, connfd;
struct sockaddr_in serv_addr, cli_addr;
socklen_t clilen;
char *buf = "hello";
char rec_buf[256];
bzero(&serv_addr,sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = inet_addr("x.x.x.x");
serv_addr.sin_port = htons(32000);
sockfd = socket(AF_INET, SOCK_STREAM, 0);
connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
write(sockfd, buf, strlen(buf));
read(sockfd, recv_buf, 255);
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 35 / 50
Internet Socket Addresses
An IPv4 socket address is stored in a sockaddr in structure, deļ¬ned
in <netinet/in.h>.
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
struct sockaddr {
sa_family_t sa_family; // Address family (AF_* constant)
char sa_data[14]; // Socket address
};
struct sockaddr_in { // IPv4 socket address
sa_family_t sin_family; // Address family (AF_INET)
in_port_t sin_port; // Port number
struct in_addr sin_addr; // IPv4 address
unsigned char _pad[X]; // Pad to size of ā€™sockaddrā€™ structure (16 bytes)
};
struct in_addr { // IPv4 4-byte address
in_addr_t s_addr; // Unsigned 32-bit integer
};
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 36 / 50
Datagram Sockets
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 37 / 50
Exchanging Datagrams
recvfrom() and sendto() receive and send datagrams on a data-
gram socket.
#include <sys/socket.h>
ssize_t sendto(int sockfd, const void *buffer, size_t length, int flags,
const struct sockaddr *dest_addr, socklen_t addrlen);
ssize_t recvfrom(int sockfd, void *buffer, size_t length, int flags,
struct sockaddr *src_addr, socklen_t *addrlen);
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 38 / 50
Producer-Consumer vi Datagram Socket (1/2)
Producer (Server)
int sockfd, n;
struct sockaddr_in serv_addr, cli_addr;
socklen_t cli_len;
char buf[256];
bzero(&serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
serv_addr.sin_port = htons(32000);
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
bind(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
cli_len = sizeof(cli_addr);
n = recvfrom(sockfd, buf, 255, 0, (struct sockaddr *)&cli_addr, &cli_len);
sendto(sockfd, buf, n, 0, (struct sockaddr *)&cli_addr,sizeof(cli_addr));
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 39 / 50
Producer-Consumer vi Datagram Socket (2/2)
Consumer (Client)
int sockfd, connfd;
struct sockaddr_in serv_addr, cli_addr;
socklen_t clilen;
char *buf = "hello";
char recv_buf[256];
bzero(&serv_addr,sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = inet_addr("x.x.x.x");
serv_addr.sin_port = htons(32000);
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
sendto(sockfd, buf, strlen(buf), 0, (struct sockaddr *)&serv_addr,
sizeof(serv_addr));
recvfrom(sockfd, recv_buf, 255, 0, NULL, NULL);
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 40 / 50
Signals
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 41 / 50
Signals (1/2)
Signals are software interrupts to notify a process that a particular
event has occurred.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 42 / 50
Signals (1/2)
Signals are software interrupts to notify a process that a particular
event has occurred.
These events can originate from outside the system, e.g., by pressing
Ctrl-C, or when a process executes code that divides by zero.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 42 / 50
Signals (1/2)
Signals are software interrupts to notify a process that a particular
event has occurred.
These events can originate from outside the system, e.g., by pressing
Ctrl-C, or when a process executes code that divides by zero.
As a primitive form of IPC, one process can also send a signal to
another process.
ps -aux | grep acrobat
amir 7302 0.0 0.0 ...
kill -9 7302
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 42 / 50
Signals (2/2)
A signal handler is used to process signals.
1 Signal is generated by particular event.
2 Signal is delivered to a process.
3 Signal is handled by one of two signal handlers: default or
user-deļ¬ned.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 43 / 50
Signals (2/2)
A signal handler is used to process signals.
1 Signal is generated by particular event.
2 Signal is delivered to a process.
3 Signal is handled by one of two signal handlers: default or
user-deļ¬ned.
Every signal has default handler that kernel runs when handling
signal
User-deļ¬ned signal handler can override default.
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 43 / 50
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 44 / 50
Signal Management
signal() removes the current action taken on receipt of the sig-
nal signo and instead handles the signal with the signal handler
speciļ¬ed by handler.
#include <signal.h>
typedef void (*sighandler_t)(int);
sighandler_t signal(int signo, sighandler_t handler);
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 45 / 50
Waiting for a Signal
pause() puts a process to sleep until it receives a signal.
#include <unistd.h>
int pause(void);
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 46 / 50
Signal Example
// handler for SIGINT
static void sigint_handler(int signo) {
printf("Caught SIGINT!n");
exit(0);
}
int main(void) {
// Register sigint_handler as our signal handler for SIGINT.
if (signal(SIGINT, sigint_handler) == SIG_ERR)
exit(1);
pause();
return 0;
}
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 47 / 50
Summary
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 48 / 50
Summary
TCP-IP protocol layers: data-link, network, transport, application
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 49 / 50
Summary
TCP-IP protocol layers: data-link, network, transport, application
Data-link: network card
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 49 / 50
Summary
TCP-IP protocol layers: data-link, network, transport, application
Data-link: network card
Network layer: routing, IP, 32-bit address, 16-bit port
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 49 / 50
Summary
TCP-IP protocol layers: data-link, network, transport, application
Data-link: network card
Network layer: routing, IP, 32-bit address, 16-bit port
Transport layer: TCP (stream, connection-oriented), UDP (data-
gram, connectionless)
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 49 / 50
Summary
TCP-IP protocol layers: data-link, network, transport, application
Data-link: network card
Network layer: routing, IP, 32-bit address, 16-bit port
Transport layer: TCP (stream, connection-oriented), UDP (data-
gram, connectionless)
Sockets
Signal: software interrupts
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 49 / 50
Questions?
Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 50 / 50

More Related Content

What's hot

Process Synchronization - Part1
Process Synchronization -  Part1Process Synchronization -  Part1
Process Synchronization - Part1Amir Payberah
Ā 
CPU Scheduling - Part2
CPU Scheduling - Part2CPU Scheduling - Part2
CPU Scheduling - Part2Amir Payberah
Ā 
Main Memory - Part2
Main Memory - Part2Main Memory - Part2
Main Memory - Part2Amir Payberah
Ā 
Cloud Computing
Cloud ComputingCloud Computing
Cloud ComputingAmir Payberah
Ā 
Virtual Memory - Part2
Virtual Memory - Part2Virtual Memory - Part2
Virtual Memory - Part2Amir Payberah
Ā 
Pipelining of Processors
Pipelining of ProcessorsPipelining of Processors
Pipelining of ProcessorsGaditek
Ā 
IO Management
IO ManagementIO Management
IO ManagementJ.T.A.JONES
Ā 
Pipelinig hazardous
Pipelinig hazardousPipelinig hazardous
Pipelinig hazardousjasscheema
Ā 
Operating Systems 1 (11/12) - Input / Output
Operating Systems 1 (11/12) - Input / OutputOperating Systems 1 (11/12) - Input / Output
Operating Systems 1 (11/12) - Input / OutputPeter Trƶger
Ā 
Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulationSanjeev Patel
Ā 
Chapter 13 - I/O Systems
Chapter 13 - I/O SystemsChapter 13 - I/O Systems
Chapter 13 - I/O SystemsWayne Jones Jnr
Ā 
Chapter6 pipelining
Chapter6  pipeliningChapter6  pipelining
Chapter6 pipeliningGurpreet Singh
Ā 
Presentation on risc pipeline
Presentation on risc pipelinePresentation on risc pipeline
Presentation on risc pipelineArijit Chakraborty
Ā 

What's hot (20)

Process Synchronization - Part1
Process Synchronization -  Part1Process Synchronization -  Part1
Process Synchronization - Part1
Ā 
CPU Scheduling - Part2
CPU Scheduling - Part2CPU Scheduling - Part2
CPU Scheduling - Part2
Ā 
Deadlocks
DeadlocksDeadlocks
Deadlocks
Ā 
Main Memory - Part2
Main Memory - Part2Main Memory - Part2
Main Memory - Part2
Ā 
Cloud Computing
Cloud ComputingCloud Computing
Cloud Computing
Ā 
Virtual Memory - Part2
Virtual Memory - Part2Virtual Memory - Part2
Virtual Memory - Part2
Ā 
main memory
main memorymain memory
main memory
Ā 
Pipelining of Processors
Pipelining of ProcessorsPipelining of Processors
Pipelining of Processors
Ā 
IO Management
IO ManagementIO Management
IO Management
Ā 
Pipelining in computer architecture
Pipelining in computer architecturePipelining in computer architecture
Pipelining in computer architecture
Ā 
Pipelining In computer
Pipelining In computer Pipelining In computer
Pipelining In computer
Ā 
Pipelinig hazardous
Pipelinig hazardousPipelinig hazardous
Pipelinig hazardous
Ā 
Operating Systems 1 (11/12) - Input / Output
Operating Systems 1 (11/12) - Input / OutputOperating Systems 1 (11/12) - Input / Output
Operating Systems 1 (11/12) - Input / Output
Ā 
Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulation
Ā 
Chapter 13 - I/O Systems
Chapter 13 - I/O SystemsChapter 13 - I/O Systems
Chapter 13 - I/O Systems
Ā 
Chapter6 pipelining
Chapter6  pipeliningChapter6  pipelining
Chapter6 pipelining
Ā 
A044050107
A044050107A044050107
A044050107
Ā 
Chapter1-Introduction.pdf
Chapter1-Introduction.pdfChapter1-Introduction.pdf
Chapter1-Introduction.pdf
Ā 
Io system
Io systemIo system
Io system
Ā 
Presentation on risc pipeline
Presentation on risc pipelinePresentation on risc pipeline
Presentation on risc pipeline
Ā 

Viewers also liked

P2P Content Distribution Network
P2P Content Distribution NetworkP2P Content Distribution Network
P2P Content Distribution NetworkAmir Payberah
Ā 
The Stratosphere Big Data Analytics Platform
The Stratosphere Big Data Analytics PlatformThe Stratosphere Big Data Analytics Platform
The Stratosphere Big Data Analytics PlatformAmir Payberah
Ā 
Data Intensive Computing Frameworks
Data Intensive Computing FrameworksData Intensive Computing Frameworks
Data Intensive Computing FrameworksAmir Payberah
Ā 
File System Interface
File System InterfaceFile System Interface
File System InterfaceAmir Payberah
Ā 
CPU Scheduling - Part1
CPU Scheduling - Part1CPU Scheduling - Part1
CPU Scheduling - Part1Amir Payberah
Ā 
Virtual Memory - Part1
Virtual Memory - Part1Virtual Memory - Part1
Virtual Memory - Part1Amir Payberah
Ā 
File System Implementation - Part1
File System Implementation - Part1File System Implementation - Part1
File System Implementation - Part1Amir Payberah
Ā 
Main Memory - Part1
Main Memory - Part1Main Memory - Part1
Main Memory - Part1Amir Payberah
Ā 
Distributed Hash Table
Distributed Hash TableDistributed Hash Table
Distributed Hash TableAmir Payberah
Ā 
Google File System
Google File SystemGoogle File System
Google File SystemAmir Payberah
Ā 
File System Implementation - Part2
File System Implementation - Part2File System Implementation - Part2
File System Implementation - Part2Amir Payberah
Ā 
Graph processing - Pregel
Graph processing - PregelGraph processing - Pregel
Graph processing - PregelAmir Payberah
Ā 
Spark Stream and SEEP
Spark Stream and SEEPSpark Stream and SEEP
Spark Stream and SEEPAmir Payberah
Ā 

Viewers also liked (16)

P2P Content Distribution Network
P2P Content Distribution NetworkP2P Content Distribution Network
P2P Content Distribution Network
Ā 
Threads
ThreadsThreads
Threads
Ā 
Security
SecuritySecurity
Security
Ā 
Storage
StorageStorage
Storage
Ā 
The Stratosphere Big Data Analytics Platform
The Stratosphere Big Data Analytics PlatformThe Stratosphere Big Data Analytics Platform
The Stratosphere Big Data Analytics Platform
Ā 
Data Intensive Computing Frameworks
Data Intensive Computing FrameworksData Intensive Computing Frameworks
Data Intensive Computing Frameworks
Ā 
File System Interface
File System InterfaceFile System Interface
File System Interface
Ā 
CPU Scheduling - Part1
CPU Scheduling - Part1CPU Scheduling - Part1
CPU Scheduling - Part1
Ā 
Virtual Memory - Part1
Virtual Memory - Part1Virtual Memory - Part1
Virtual Memory - Part1
Ā 
File System Implementation - Part1
File System Implementation - Part1File System Implementation - Part1
File System Implementation - Part1
Ā 
Main Memory - Part1
Main Memory - Part1Main Memory - Part1
Main Memory - Part1
Ā 
Distributed Hash Table
Distributed Hash TableDistributed Hash Table
Distributed Hash Table
Ā 
Google File System
Google File SystemGoogle File System
Google File System
Ā 
File System Implementation - Part2
File System Implementation - Part2File System Implementation - Part2
File System Implementation - Part2
Ā 
Graph processing - Pregel
Graph processing - PregelGraph processing - Pregel
Graph processing - Pregel
Ā 
Spark Stream and SEEP
Spark Stream and SEEPSpark Stream and SEEP
Spark Stream and SEEP
Ā 

Similar to Process Management - Part3

U5CSS3 (1).pdf
U5CSS3 (1).pdfU5CSS3 (1).pdf
U5CSS3 (1).pdfchelsi33
Ā 
presentation on TCP/IP protocols data comunications
presentation on TCP/IP protocols data comunicationspresentation on TCP/IP protocols data comunications
presentation on TCP/IP protocols data comunicationsAnyapuPranav
Ā 
Wireshark - Basics
Wireshark - BasicsWireshark - Basics
Wireshark - BasicsYoram Orzach
Ā 
CN-OSI-TCP-Models-001.pdf
CN-OSI-TCP-Models-001.pdfCN-OSI-TCP-Models-001.pdf
CN-OSI-TCP-Models-001.pdfskknowledge
Ā 
02-ProtocolArchitecture.pdf
02-ProtocolArchitecture.pdf02-ProtocolArchitecture.pdf
02-ProtocolArchitecture.pdfMiftaNurFarid2
Ā 
TCP IP PowerPoint presentation download.
TCP IP PowerPoint presentation download.TCP IP PowerPoint presentation download.
TCP IP PowerPoint presentation download.rp5373568
Ā 
More on Tcp/Ip
More on Tcp/IpMore on Tcp/Ip
More on Tcp/IpRakhi Saxena
Ā 
Communication Networks 1
Communication Networks 1Communication Networks 1
Communication Networks 1mahamed Ayesh
Ā 
Computer network coe351- part2- final
Computer network coe351- part2- finalComputer network coe351- part2- final
Computer network coe351- part2- finalTaymoor Nazmy
Ā 
pppppppppppppppppjjjjjjjjjjjpppppppp.pptx
pppppppppppppppppjjjjjjjjjjjpppppppp.pptxpppppppppppppppppjjjjjjjjjjjpppppppp.pptx
pppppppppppppppppjjjjjjjjjjjpppppppp.pptxzeyadosama505
Ā 
Aplication and Transport layer- a practical approach
Aplication and Transport layer-  a practical approachAplication and Transport layer-  a practical approach
Aplication and Transport layer- a practical approachSarah R. Dowlath
Ā 

Similar to Process Management - Part3 (20)

U5CSS3 (1).pdf
U5CSS3 (1).pdfU5CSS3 (1).pdf
U5CSS3 (1).pdf
Ā 
TCP/IP Introduction
TCP/IP IntroductionTCP/IP Introduction
TCP/IP Introduction
Ā 
presentation on TCP/IP protocols data comunications
presentation on TCP/IP protocols data comunicationspresentation on TCP/IP protocols data comunications
presentation on TCP/IP protocols data comunications
Ā 
TCP/IP Modal
TCP/IP ModalTCP/IP Modal
TCP/IP Modal
Ā 
OSI Layers
OSI LayersOSI Layers
OSI Layers
Ā 
02 protocol architecture
02 protocol architecture02 protocol architecture
02 protocol architecture
Ā 
Wireshark - Basics
Wireshark - BasicsWireshark - Basics
Wireshark - Basics
Ā 
CN-OSI-TCP-Models-001.pdf
CN-OSI-TCP-Models-001.pdfCN-OSI-TCP-Models-001.pdf
CN-OSI-TCP-Models-001.pdf
Ā 
02-ProtocolArchitecture.pdf
02-ProtocolArchitecture.pdf02-ProtocolArchitecture.pdf
02-ProtocolArchitecture.pdf
Ā 
TCP IP PowerPoint presentation download.
TCP IP PowerPoint presentation download.TCP IP PowerPoint presentation download.
TCP IP PowerPoint presentation download.
Ā 
More on Tcp/Ip
More on Tcp/IpMore on Tcp/Ip
More on Tcp/Ip
Ā 
Communication Networks 1
Communication Networks 1Communication Networks 1
Communication Networks 1
Ā 
Internet1
Internet1Internet1
Internet1
Ā 
Osi model
Osi modelOsi model
Osi model
Ā 
Computer network coe351- part2- final
Computer network coe351- part2- finalComputer network coe351- part2- final
Computer network coe351- part2- final
Ā 
Ta 104-tcp
Ta 104-tcpTa 104-tcp
Ta 104-tcp
Ā 
pppppppppppppppppjjjjjjjjjjjpppppppp.pptx
pppppppppppppppppjjjjjjjjjjjpppppppp.pptxpppppppppppppppppjjjjjjjjjjjpppppppp.pptx
pppppppppppppppppjjjjjjjjjjjpppppppp.pptx
Ā 
TCP Vs UDP
TCP Vs UDP TCP Vs UDP
TCP Vs UDP
Ā 
Lecture 3- tcp-ip
Lecture  3- tcp-ipLecture  3- tcp-ip
Lecture 3- tcp-ip
Ā 
Aplication and Transport layer- a practical approach
Aplication and Transport layer-  a practical approachAplication and Transport layer-  a practical approach
Aplication and Transport layer- a practical approach
Ā 

Recently uploaded

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
Ā 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
Ā 
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøcall girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøDelhi Call girls
Ā 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfWilly Marroquin (WillyDevNET)
Ā 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
Ā 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
Ā 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
Ā 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
Ā 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
Ā 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
Ā 
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...Steffen Staab
Ā 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
Ā 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
Ā 
(Genuine) Escort Service Lucknow | Starting ā‚¹,5K To @25k with A/C šŸ§‘šŸ½ā€ā¤ļøā€šŸ§‘šŸ» 89...
(Genuine) Escort Service Lucknow | Starting ā‚¹,5K To @25k with A/C šŸ§‘šŸ½ā€ā¤ļøā€šŸ§‘šŸ» 89...(Genuine) Escort Service Lucknow | Starting ā‚¹,5K To @25k with A/C šŸ§‘šŸ½ā€ā¤ļøā€šŸ§‘šŸ» 89...
(Genuine) Escort Service Lucknow | Starting ā‚¹,5K To @25k with A/C šŸ§‘šŸ½ā€ā¤ļøā€šŸ§‘šŸ» 89...gurkirankumar98700
Ā 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
Ā 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
Ā 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
Ā 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
Ā 

Recently uploaded (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
Ā 
Call Girls In Mukherjee Nagar šŸ“± 9999965857 šŸ¤© Delhi šŸ«¦ HOT AND SEXY VVIP šŸŽ SE...
Call Girls In Mukherjee Nagar šŸ“±  9999965857  šŸ¤© Delhi šŸ«¦ HOT AND SEXY VVIP šŸŽ SE...Call Girls In Mukherjee Nagar šŸ“±  9999965857  šŸ¤© Delhi šŸ«¦ HOT AND SEXY VVIP šŸŽ SE...
Call Girls In Mukherjee Nagar šŸ“± 9999965857 šŸ¤© Delhi šŸ«¦ HOT AND SEXY VVIP šŸŽ SE...
Ā 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Ā 
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøcall girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
Ā 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
Ā 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
Ā 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Ā 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
Ā 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
Ā 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
Ā 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Ā 
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...
Ā 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
Ā 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
Ā 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
Ā 
(Genuine) Escort Service Lucknow | Starting ā‚¹,5K To @25k with A/C šŸ§‘šŸ½ā€ā¤ļøā€šŸ§‘šŸ» 89...
(Genuine) Escort Service Lucknow | Starting ā‚¹,5K To @25k with A/C šŸ§‘šŸ½ā€ā¤ļøā€šŸ§‘šŸ» 89...(Genuine) Escort Service Lucknow | Starting ā‚¹,5K To @25k with A/C šŸ§‘šŸ½ā€ā¤ļøā€šŸ§‘šŸ» 89...
(Genuine) Escort Service Lucknow | Starting ā‚¹,5K To @25k with A/C šŸ§‘šŸ½ā€ā¤ļøā€šŸ§‘šŸ» 89...
Ā 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
Ā 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
Ā 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
Ā 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
Ā 

Process Management - Part3

  • 1. Processes (Part III) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 1 / 50
  • 2. Inter-Process Communication (IPC) Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 2 / 50
  • 3. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 3 / 50
  • 4. Socket Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 4 / 50
  • 5. Letā€™s First Review The Basic Concepts of TCP/IP Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 5 / 50
  • 6. Internetworking An internetwork (internet (with a lowercase i)) is a network of com- puter networks. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 6 / 50
  • 7. Internetworking An internetwork (internet (with a lowercase i)) is a network of com- puter networks. Subnetwork refers to one of the networks composing an internet. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 6 / 50
  • 8. Internetworking An internetwork (internet (with a lowercase i)) is a network of com- puter networks. Subnetwork refers to one of the networks composing an internet. An internet aims to hide the details of diļ¬€erent physical networks, to present a uniļ¬ed network architecture. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 6 / 50
  • 9. The Internet TCP/IP has become the dominant protocol for the internetworking. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 7 / 50
  • 10. The Internet TCP/IP has become the dominant protocol for the internetworking. The Internet (with an uppercase I) refers to the TCP/IP internet that connects millions of computers globally. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 7 / 50
  • 11. The Internet TCP/IP has become the dominant protocol for the internetworking. The Internet (with an uppercase I) refers to the TCP/IP internet that connects millions of computers globally. The ļ¬rst widespread implementation of TCP/IP appeared with 4.2BSD in 1983. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 7 / 50
  • 12. Networking Protocols and Layers A networking protocol is a set of rules deļ¬ning how information is to be transmitted across a network. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 8 / 50
  • 13. Networking Protocols and Layers A networking protocol is a set of rules deļ¬ning how information is to be transmitted across a network. Networking protocols are generally organized as a series of layers. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 8 / 50
  • 14. Networking Protocols and Layers A networking protocol is a set of rules deļ¬ning how information is to be transmitted across a network. Networking protocols are generally organized as a series of layers. Each layer building on the layer below it to add features that are made available to higher layers. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 8 / 50
  • 15. Networking Protocols and Layers A networking protocol is a set of rules deļ¬ning how information is to be transmitted across a network. Networking protocols are generally organized as a series of layers. Each layer building on the layer below it to add features that are made available to higher layers. Transparency: each protocol layer shields higher layers from the operation and complexity of lower layers. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 8 / 50
  • 16. TCP/IP Protocol Suite The TCP/IP protocol suite is a layered networking protocol. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 9 / 50
  • 17. TCP/IP Protocol Layers Data-Link layer Network layer (IP) Transport layer (TCP, UDP) Application Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 10 / 50
  • 18. Encapsulation Encapsulation: the information passed from a higher layer to a lower layer is treated as opaque data by the lower layer. ā€¢ The lower layer does not interpret information from the upper layer. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 11 / 50
  • 19. Encapsulation Encapsulation: the information passed from a higher layer to a lower layer is treated as opaque data by the lower layer. ā€¢ The lower layer does not interpret information from the upper layer. When data is passed up from a lower layer to a higher layer, a converse unpacking process takes place. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 11 / 50
  • 20. Data-Link Layer (1/3) It is concerned with transferring data across a physical link in a network. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 12 / 50
  • 21. Data-Link Layer (1/3) It is concerned with transferring data across a physical link in a network. It consists of the device driver and the hardware interface (network card) to the underlying physical medium, e.g., ļ¬ber-optic cable. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 12 / 50
  • 22. Data-Link Layer (2/3) The data-link layer encapsulates datagrams from the network layer into units, called frames. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 13 / 50
  • 23. Data-Link Layer (2/3) The data-link layer encapsulates datagrams from the network layer into units, called frames. It also adds each frame a header containing the destination address and frame size. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 13 / 50
  • 24. Data-Link Layer (2/3) The data-link layer encapsulates datagrams from the network layer into units, called frames. It also adds each frame a header containing the destination address and frame size. The data-link layer transmits the frames across the physical link and handles acknowledgements from the receiver. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 13 / 50
  • 25. Data-Link Layer (3/3) From an application-programming point of view, we can generally ignore the data-link layer, since all communication details are han- dled in the driver and hardware. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 14 / 50
  • 26. Data-Link Layer (3/3) From an application-programming point of view, we can generally ignore the data-link layer, since all communication details are han- dled in the driver and hardware. Maximum Transmission Unit (MTU): the upper limit that the layer places on the size of a frame. ā€¢ data-link layers have diļ¬€erent MTUs. netstat -i Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 14 / 50
  • 27. Network Layer (1/4) It is concerned with delivering data from the source host to the destination host. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 15 / 50
  • 28. Network Layer (1/4) It is concerned with delivering data from the source host to the destination host. It tasks include: ā€¢ Breaking data into fragments small enough for transmission via the data-link layer. ā€¢ Routing data across the internet. ā€¢ Providing services to the transport layer. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 15 / 50
  • 29. Network Layer (1/4) It is concerned with delivering data from the source host to the destination host. It tasks include: ā€¢ Breaking data into fragments small enough for transmission via the data-link layer. ā€¢ Routing data across the internet. ā€¢ Providing services to the transport layer. In the TCP/IP protocol suite, the principal protocol in the network layer is IP. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 15 / 50
  • 30. Network Layer (2/4) IP transmits data in the form of packets. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 16 / 50
  • 31. Network Layer (2/4) IP transmits data in the form of packets. Each packet sent between two hosts travels independently across the network. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 16 / 50
  • 32. Network Layer (2/4) IP transmits data in the form of packets. Each packet sent between two hosts travels independently across the network. An IP packet includes a header that contains the address of the source and target hosts. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 16 / 50
  • 33. Network Layer (3/4) IP is a connectionless protocol: it does not provide a virtual circuit connecting two hosts. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 17 / 50
  • 34. Network Layer (3/4) IP is a connectionless protocol: it does not provide a virtual circuit connecting two hosts. IP is an unreliable protocol: it makes a best eļ¬€ort to transmit data- grams from the sender to the receiver, but it does not guarantee: ā€¢ that packets will arrive in the order they were transmitted, ā€¢ that they will not be duplicated, ā€¢ that they will arrive at all. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 17 / 50
  • 35. Network Layer (4/4) An IP address consists of two parts: ā€¢ Network ID: speciļ¬es the network on which a host resides. ā€¢ Host ID: identiļ¬es the host within that network. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 18 / 50
  • 36. Network Layer (4/4) An IP address consists of two parts: ā€¢ Network ID: speciļ¬es the network on which a host resides. ā€¢ Host ID: identiļ¬es the host within that network. An IPv4 address consists of 32 bits: 204.152.189.0/24 ā€¢ loopback 127.0.0.1 refers to system on which process is running. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 18 / 50
  • 37. Network Layer (4/4) An IP address consists of two parts: ā€¢ Network ID: speciļ¬es the network on which a host resides. ā€¢ Host ID: identiļ¬es the host within that network. An IPv4 address consists of 32 bits: 204.152.189.0/24 ā€¢ loopback 127.0.0.1 refers to system on which process is running. Network mask: a sequence of 1s in the leftmost bits, followed by a sequence of 0s ā€¢ The 1s indicate which part of the address contains the assigned network ID. ā€¢ The 0s indicate which part of the address is available to assign as host IDs. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 18 / 50
  • 38. Transport Layer (1/5) Transport protocol provides an end-to-end communication service to applications residing on diļ¬€erent hosts. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 19 / 50
  • 39. Transport Layer (1/5) Transport protocol provides an end-to-end communication service to applications residing on diļ¬€erent hosts. Two widely used transport-layer protocols in the TCP/IP suite: ā€¢ User Datagram Protocol (UDP): the protocol used for datagram sockets. ā€¢ Transmission Control Protocol (TCP): the protocol used for stream sockets. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 19 / 50
  • 40. Transport Layer (2/5) Port: a method of diļ¬€erentiating the applications on a host. ā€¢ 16-bit number Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 20 / 50
  • 41. Transport Layer (2/5) Port: a method of diļ¬€erentiating the applications on a host. ā€¢ 16-bit number ā€¢ All ports below 1024 are well known, used for standard services, e.g., http: 80, ssh: 22. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 20 / 50
  • 42. Transport Layer (2/5) Port: a method of diļ¬€erentiating the applications on a host. ā€¢ 16-bit number ā€¢ All ports below 1024 are well known, used for standard services, e.g., http: 80, ssh: 22. ā€¢ Shown as 192.168.1.1:8080. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 20 / 50
  • 43. Transport Layer (3/5) UDP, like IP, is connectionless and unreliable. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 21 / 50
  • 44. Transport Layer (3/5) UDP, like IP, is connectionless and unreliable. If an application layered on top of UDP requires reliability, then this must be implemented within the application. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 21 / 50
  • 45. Transport Layer (3/5) UDP, like IP, is connectionless and unreliable. If an application layered on top of UDP requires reliability, then this must be implemented within the application. UDP adds just two features to IP: ā€¢ Port number ā€¢ Data checksum to allow the detection of errors in the transmitted data. [http://www.tamos.net/āˆ¼rhay/overhead/ip-packet-overhead.htm] Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 21 / 50
  • 46. Transport Layer (4/5) TCP provides a reliable, connection-oriented, bidirectional, byte- stream communication channel between two endpoints. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 22 / 50
  • 47. Transport Layer (4/5) TCP provides a reliable, connection-oriented, bidirectional, byte- stream communication channel between two endpoints. Before communication can commence, TCP establishes a commu- nication channel between the two endpoints. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 22 / 50
  • 48. Transport Layer (5/5) In TCP, data is broken into segments: each is transmitted in a single IP packet. [http://www.tamos.net/āˆ¼rhay/overhead/ip-packet-overhead.htm] Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 23 / 50
  • 49. Transport Layer (5/5) In TCP, data is broken into segments: each is transmitted in a single IP packet. When a destination receives a TCP segment, it sends an ack. to the sender, informing weather it received the segment correctly or not. [http://www.tamos.net/āˆ¼rhay/overhead/ip-packet-overhead.htm] Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 23 / 50
  • 50. Transport Layer (5/5) In TCP, data is broken into segments: each is transmitted in a single IP packet. When a destination receives a TCP segment, it sends an ack. to the sender, informing weather it received the segment correctly or not. Other features of TCP: ā€¢ Sequencing ā€¢ Flow control ā€¢ Congestion control [http://www.tamos.net/āˆ¼rhay/overhead/ip-packet-overhead.htm] Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 23 / 50
  • 51. OK, Letā€™s Back to Socket Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 24 / 50
  • 52. Socket A socket is deļ¬ned as an endpoint for communication. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 25 / 50
  • 53. Socket A socket is deļ¬ned as an endpoint for communication. A typical client-server scenario: ā€¢ Each process creates a socket: both processes require one. ā€¢ The server binds its socket to a well-known address (name) so that clients can locate it. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 25 / 50
  • 54. Creating a Socket socket() creates a new socket. #include <sys/socket.h> int socket(int domain, int type, int protocol); Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 26 / 50
  • 55. Socket Domains The UNIX domain (AF UNIX) ā€¢ Communication between processes on the same host (within the kernel). ā€¢ Address format: path name. int socket(int domain, int type, int protocol); Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 27 / 50
  • 56. Socket Domains The UNIX domain (AF UNIX) ā€¢ Communication between processes on the same host (within the kernel). ā€¢ Address format: path name. The IPV4 domain (AF INET) ā€¢ Communication between processes running on hosts connected via an IPv4 network. ā€¢ Address format: 32-bit IPv4 address + 16-bit port number. int socket(int domain, int type, int protocol); Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 27 / 50
  • 57. Socket Types Stream sockets (SOCK STREAM) ā€¢ It provides a reliable, bidirectional, byte-stream communication channel. ā€¢ Called connection-oriented. int socket(int domain, int type, int protocol); Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 28 / 50
  • 58. Socket Types Stream sockets (SOCK STREAM) ā€¢ It provides a reliable, bidirectional, byte-stream communication channel. ā€¢ Called connection-oriented. Datagram sockets (SOCK DGRAM) ā€¢ Allow data to be exchanged in the form of messages called datagrams. ā€¢ Called connectionless. int socket(int domain, int type, int protocol); Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 28 / 50
  • 59. Binding a Socket to an Address bind() binds a socket to an address. #include <sys/socket.h> int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen); Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 29 / 50
  • 60. Listening for Incoming Connections listen() marks the stream socket passive. The socket will subsequently be used to accept connections from other (active) sockets. #include <sys/socket.h> int listen(int sockfd, int backlog); Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 30 / 50
  • 61. Accepting a Connection accept() accepts an incoming connection on the listening stream socket. If there are no pending connections when accept() is called, the call blocks until a connection request arrives. #include <sys/socket.h> int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 31 / 50
  • 62. Connecting to a Peer Socket connect() connects the active socket to the listening socket whose address is speciļ¬ed by addr and addrlen. #include <sys/socket.h> int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 32 / 50
  • 63. Stream Sockets Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 33 / 50
  • 64. Producer-Consumer vi Stream Socket (1/2) Producer (Server) int sockfd, connfd; struct sockaddr_in serv_addr, cli_addr; socklen_t cli_len; char buffer[256]; bzero(&serv_addr, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); serv_addr.sin_port = htons(32000); sockfd = socket(AF_INET, SOCK_STREAM, 0); bind(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)); listen(sockfd, 5); cli_len = sizeof(cli_addr); connfd = accept(sockfd, (struct sockaddr *)&cli_addr, &cli_len); read(connfd, buffer, 255); write(connfd, "I got your message", 18); Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 34 / 50
  • 65. Producer-Consumer vi Stream Socket (2/2) Consumer (Client) int sockfd, connfd; struct sockaddr_in serv_addr, cli_addr; socklen_t clilen; char *buf = "hello"; char rec_buf[256]; bzero(&serv_addr,sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = inet_addr("x.x.x.x"); serv_addr.sin_port = htons(32000); sockfd = socket(AF_INET, SOCK_STREAM, 0); connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)); write(sockfd, buf, strlen(buf)); read(sockfd, recv_buf, 255); Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 35 / 50
  • 66. Internet Socket Addresses An IPv4 socket address is stored in a sockaddr in structure, deļ¬ned in <netinet/in.h>. int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen); struct sockaddr { sa_family_t sa_family; // Address family (AF_* constant) char sa_data[14]; // Socket address }; struct sockaddr_in { // IPv4 socket address sa_family_t sin_family; // Address family (AF_INET) in_port_t sin_port; // Port number struct in_addr sin_addr; // IPv4 address unsigned char _pad[X]; // Pad to size of ā€™sockaddrā€™ structure (16 bytes) }; struct in_addr { // IPv4 4-byte address in_addr_t s_addr; // Unsigned 32-bit integer }; Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 36 / 50
  • 67. Datagram Sockets Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 37 / 50
  • 68. Exchanging Datagrams recvfrom() and sendto() receive and send datagrams on a data- gram socket. #include <sys/socket.h> ssize_t sendto(int sockfd, const void *buffer, size_t length, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); ssize_t recvfrom(int sockfd, void *buffer, size_t length, int flags, struct sockaddr *src_addr, socklen_t *addrlen); Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 38 / 50
  • 69. Producer-Consumer vi Datagram Socket (1/2) Producer (Server) int sockfd, n; struct sockaddr_in serv_addr, cli_addr; socklen_t cli_len; char buf[256]; bzero(&serv_addr, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); serv_addr.sin_port = htons(32000); sockfd = socket(AF_INET, SOCK_DGRAM, 0); bind(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)); cli_len = sizeof(cli_addr); n = recvfrom(sockfd, buf, 255, 0, (struct sockaddr *)&cli_addr, &cli_len); sendto(sockfd, buf, n, 0, (struct sockaddr *)&cli_addr,sizeof(cli_addr)); Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 39 / 50
  • 70. Producer-Consumer vi Datagram Socket (2/2) Consumer (Client) int sockfd, connfd; struct sockaddr_in serv_addr, cli_addr; socklen_t clilen; char *buf = "hello"; char recv_buf[256]; bzero(&serv_addr,sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = inet_addr("x.x.x.x"); serv_addr.sin_port = htons(32000); sockfd = socket(AF_INET, SOCK_DGRAM, 0); sendto(sockfd, buf, strlen(buf), 0, (struct sockaddr *)&serv_addr, sizeof(serv_addr)); recvfrom(sockfd, recv_buf, 255, 0, NULL, NULL); Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 40 / 50
  • 71. Signals Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 41 / 50
  • 72. Signals (1/2) Signals are software interrupts to notify a process that a particular event has occurred. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 42 / 50
  • 73. Signals (1/2) Signals are software interrupts to notify a process that a particular event has occurred. These events can originate from outside the system, e.g., by pressing Ctrl-C, or when a process executes code that divides by zero. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 42 / 50
  • 74. Signals (1/2) Signals are software interrupts to notify a process that a particular event has occurred. These events can originate from outside the system, e.g., by pressing Ctrl-C, or when a process executes code that divides by zero. As a primitive form of IPC, one process can also send a signal to another process. ps -aux | grep acrobat amir 7302 0.0 0.0 ... kill -9 7302 Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 42 / 50
  • 75. Signals (2/2) A signal handler is used to process signals. 1 Signal is generated by particular event. 2 Signal is delivered to a process. 3 Signal is handled by one of two signal handlers: default or user-deļ¬ned. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 43 / 50
  • 76. Signals (2/2) A signal handler is used to process signals. 1 Signal is generated by particular event. 2 Signal is delivered to a process. 3 Signal is handled by one of two signal handlers: default or user-deļ¬ned. Every signal has default handler that kernel runs when handling signal User-deļ¬ned signal handler can override default. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 43 / 50
  • 77. Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 44 / 50
  • 78. Signal Management signal() removes the current action taken on receipt of the sig- nal signo and instead handles the signal with the signal handler speciļ¬ed by handler. #include <signal.h> typedef void (*sighandler_t)(int); sighandler_t signal(int signo, sighandler_t handler); Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 45 / 50
  • 79. Waiting for a Signal pause() puts a process to sleep until it receives a signal. #include <unistd.h> int pause(void); Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 46 / 50
  • 80. Signal Example // handler for SIGINT static void sigint_handler(int signo) { printf("Caught SIGINT!n"); exit(0); } int main(void) { // Register sigint_handler as our signal handler for SIGINT. if (signal(SIGINT, sigint_handler) == SIG_ERR) exit(1); pause(); return 0; } Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 47 / 50
  • 81. Summary Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 48 / 50
  • 82. Summary TCP-IP protocol layers: data-link, network, transport, application Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 49 / 50
  • 83. Summary TCP-IP protocol layers: data-link, network, transport, application Data-link: network card Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 49 / 50
  • 84. Summary TCP-IP protocol layers: data-link, network, transport, application Data-link: network card Network layer: routing, IP, 32-bit address, 16-bit port Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 49 / 50
  • 85. Summary TCP-IP protocol layers: data-link, network, transport, application Data-link: network card Network layer: routing, IP, 32-bit address, 16-bit port Transport layer: TCP (stream, connection-oriented), UDP (data- gram, connectionless) Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 49 / 50
  • 86. Summary TCP-IP protocol layers: data-link, network, transport, application Data-link: network card Network layer: routing, IP, 32-bit address, 16-bit port Transport layer: TCP (stream, connection-oriented), UDP (data- gram, connectionless) Sockets Signal: software interrupts Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 49 / 50
  • 87. Questions? Amir H. Payberah (Tehran Polytechnic) Processes 1393/7/7 50 / 50