Thread Variable Optimization Entropya3b675d1
Thread Variable Optimization Entropya3b675d1
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4
prompt> ./p1
hello (pid:29146)
parent of 29147 (pid:29146)
child (pid:29147)
prompt>
O PERATING
S YSTEMS WWW. OSTEP. ORG
[V ERSION 1.10]
2 I NTERLUDE : P ROCESS API
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4
prompt> ./p1
hello (pid:29146)
parent of 29147 (pid:29146)
child (pid:29147)
prompt>
O PERATING
S YSTEMS WWW. OSTEP. ORG
[V ERSION 1.10]
2 I NTERLUDE : P ROCESS API
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4
prompt> ./p1
hello (pid:29146)
parent of 29147 (pid:29146)
child (pid:29147)
prompt>
O PERATING
S YSTEMS WWW. OSTEP. ORG
[V ERSION 1.10]
I NTERLUDE : P ROCESS API 5
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <string.h>
5 #include <sys/wait.h>
6
prompt> ./p3
hello (pid:29383)
child (pid:29384)
29 107 1030 p3.c
parent of 29384 (rc_wait:29384) (pid:29383)
prompt>
The fork() system call is strange; its partner in crime, exec(), is not
so normal either. What it does: given the name of an executable (e.g., wc),
and some arguments (e.g., p3.c), it loads code (and static data) from that
T HREE
© 2008–23, A RPACI -D USSEAU
E ASY
P IECES
I NTERLUDE : P ROCESS API 5
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <string.h>
5 #include <sys/wait.h>
6
prompt> ./p3
hello (pid:29383)
child (pid:29384)
29 107 1030 p3.c
parent of 29384 (rc_wait:29384) (pid:29383)
prompt>
The fork() system call is strange; its partner in crime, exec(), is not
so normal either. What it does: given the name of an executable (e.g., wc),
and some arguments (e.g., p3.c), it loads code (and static data) from that
T HREE
© 2008–23, A RPACI -D USSEAU
E ASY
P IECES
I NTERLUDE : P ROCESS API 5
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <string.h>
5 #include <sys/wait.h>
6
prompt> ./p3
hello (pid:29383)
child (pid:29384)
29 107 1030 p3.c
parent of 29384 (rc_wait:29384) (pid:29383)
prompt>
The fork() system call is strange; its partner in crime, exec(), is not
so normal either. What it does: given the name of an executable (e.g., wc),
and some arguments (e.g., p3.c), it loads code (and static data) from that
T HREE
© 2008–23, A RPACI -D USSEAU
E ASY
P IECES
8 I NTERLUDE : P ROCESS API
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <string.h>
5 #include <fcntl.h>
6 #include <sys/wait.h>
7
O PERATING
S YSTEMS WWW. OSTEP. ORG
[V ERSION 1.10]
8 I NTERLUDE : P ROCESS API
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <string.h>
5 #include <fcntl.h>
6 #include <sys/wait.h>
7
O PERATING
S YSTEMS WWW. OSTEP. ORG
[V ERSION 1.10]
8 I NTERLUDE : P ROCESS API
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <string.h>
5 #include <fcntl.h>
6 #include <sys/wait.h>
7
O PERATING
S YSTEMS WWW. OSTEP. ORG
[V ERSION 1.10]