tkt
This commit is contained in:
BIN
SCR3.1/TP4/Exo1/Rebours
Executable file
BIN
SCR3.1/TP4/Exo1/Rebours
Executable file
Binary file not shown.
19
SCR3.1/TP4/Exo1/Rebours.c
Normal file
19
SCR3.1/TP4/Exo1/Rebours.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int n = (int)strtol(argv[1], NULL,0);
|
||||
int pid = getpid();
|
||||
printf("%d: debut\n", pid);
|
||||
|
||||
for (int i = n; i > 0; i--) {
|
||||
printf("%d: %d\n", pid, i);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
printf("%d: fin\n", pid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
SCR3.1/TP4/Exo2/parexec
Executable file
BIN
SCR3.1/TP4/Exo2/parexec
Executable file
Binary file not shown.
20
SCR3.1/TP4/Exo2/parexec.c
Normal file
20
SCR3.1/TP4/Exo2/parexec.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int n = argc - 2;
|
||||
pid_t pids[n];
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
pids[i] = fork();
|
||||
}
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
waitpid(pids[i], NULL, 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
20
SCR3.1/TP4/Exo2/rebour.c
Normal file
20
SCR3.1/TP4/Exo2/rebour.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
assert(argc == 2);
|
||||
|
||||
int value = strtol(argv[1], NULL, 0);
|
||||
pid_t p = getpid();
|
||||
printf("%d: debut\n",p);
|
||||
for(int i = value; i>0; i--){
|
||||
printf("%d: %d\n",p,i);
|
||||
sleep(1);
|
||||
}
|
||||
printf("%d: fin\n",p);
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
BIN
SCR3.1/TP4/Exo2/rebours
Executable file
BIN
SCR3.1/TP4/Exo2/rebours
Executable file
Binary file not shown.
Reference in New Issue
Block a user