38 lines
806 B
C
38 lines
806 B
C
|
///***************************************************/
|
||
|
///* s_critique : Ce programme illustre le blocage */
|
||
|
///* du partage de temps de LINUX avec un semaphore. */
|
||
|
///***************************************************/
|
||
|
#include <stdio.h>
|
||
|
#include <unistd.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <assert.h>
|
||
|
void imprimer (int unNombre, char unCar)
|
||
|
{
|
||
|
int i;
|
||
|
for (i=0; i<unNombre; i++) printf ("%c", unCar);
|
||
|
}
|
||
|
int main(int argc, char *argv[])
|
||
|
{
|
||
|
/// FINIR ///
|
||
|
|
||
|
int nb, res;
|
||
|
assert (argc == 2);
|
||
|
nb = atoi (argv[1]);
|
||
|
res = fork();
|
||
|
if (res == -1)
|
||
|
{
|
||
|
perror ("fork");
|
||
|
exit (1);
|
||
|
}
|
||
|
if (res == 0)
|
||
|
{
|
||
|
imprimer (nb, '/');
|
||
|
return 0;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
imprimer (nb, '*');
|
||
|
return 0;
|
||
|
}
|
||
|
}
|