$ lsof -p $(pidof firefox)
[...]
firefox 32100 student 64u IPv4 38654330 0t0 TCP so:44750->lb-140-82-112-26-iad.github.com:https (ESTABLISHED)
firefox 32100 student 65u IPv4 38659353 0t0 TCP so:37528->239.237.117.34.bc.googleusercontent.com:https (ESTABLISHED)
[...]
firefox 32100 student 176u unix 0x0000000000000000 0t0 38640969 type=SEQPACKET
firefox 32100 student 178u unix 0x0000000000000000 0t0 38650545 type=SEQPACKET
firefox 32100 student 179u unix 0x0000000000000000 0t0 38648379 type=STREAM
firefox 32100 student 181r FIFO
0,13 0t0 38640924 pipe
firefox 32100 student 185u a_inode
0,14 0 11438 [eventfd]
firefox 32100 student 186uw REG
259,5 131072 17040026 /home/student/.mozilla/firefox/inonjd9q.default-release/protections.sqlite
firefox 32100 student 188u unix 0x0000000000000000 0t0 38635209 type=STREAM
[...]
firefox 32100 student 200r REG
0,1 5196 14538955 /memfd:mozilla-ipc (deleted)
[...]
#include <stdio.h>
int main(void)
{
printf("Hello, world\n");
return 0;
}
./hello_world | grep Hello
chapters/app-interact/overview/guides/comm-channels/reader.c
chapters/app-interact/overview/guides/comm-channels/writer.c
chapters/app-interact/overview/guides/comm-channels/send_receive_pipe.c
// writer.c
int main(void)
{
FILE *fp = fopen("myf.txt", "r");
fprintf(fp, "Hello");
fclose(fp);
return 0;
}
// reader.c
int main(void)
{
char a[20];
FILE *fp = fopen("myf.txt", "r");
fscanf(fp, "%s", a);
printf("%s\n", a);
fclose(fp);
return 0;
}
int main(void)
{
pid_t pid = fork();
if (pid == 0) {
sleep(2);
exit(EXIT_SUCCESS);
}
waitpid(pid, &status, 0);
return 0;
}
No actual software component interaction
Simple applications that don't rely on complex features
ldd <exec> | grep pthread
/bin/bash
, /bin/dd
Multiple threads doing the same work
Threading models: boss-workers, worker threads, thread pools
Generally little interaction: join at the end
multi-threaded web servers
libx264
library for ffmpeg
Firefox web browser: browser tabs
Multiple threads, each doing different work
Firefox web browser: browser management processes
Multiple processes doing the same work
Process pool
Generally no interaction: pre-fork, get job, serve
Multi-process web servers (Apache2 mpm-prefork)
Google Chrome: a process per Tab
Multiple processes doing different items
IPC mechanisms (pipes, message queues, sockets) to interface between processes
Postfix
GitLab
(source)
(source)
Processes run on different systems
Used in distributed systems, data centers, computing clusters
Typically a combination of homogeneous and heterogeneous systems and processes
Kubernetes, OpenStack, Netflix backend servers
(source)
App components interact via interaction channels.
lock()
/ unlock()
up()
/ down()
wait()
/ notify()
kill()
/ sigwait()
In chapters/app-interact/overview/guides/lock/
In chapters/app-interact/overview/guides/sync/
sigaction()
, kill()
, sigqueue()
, sigsuspend()
AddVectoredExceptionHandler()
, RaiseException()
In chapters/app-interact/overview/guides/interrupt/
In chapters/app-interact/overview/guides/shared-mem/
read()
/ write()
, send()
/ recv()
In /chapters/app-interact/overview/guides/comm-channels/
In /chapters/app-interact/overview/guides/fibonacci-server/