12.07.2015 Views

Généralités sur les systèmes d'exploitation - Site personnel de ...

Généralités sur les systèmes d'exploitation - Site personnel de ...

Généralités sur les systèmes d'exploitation - Site personnel de ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

LO14 : Université Technologique <strong>de</strong> TroyesT1T2T1V(S)on remplace parP(S)T2Il suffit <strong>de</strong> remplacer la précé<strong>de</strong>nce commeindiqué ci-contre. On peut ensuite lancer T1 et T2en parallèle sans problème.Exemple traité en cours.et init(S,0);V) Processus et LINUX1°) Structure <strong>de</strong>s processusSi <strong>de</strong>ux utilisateurs trac et truc utilisent l'utilitaire grep en même temps voilà ce qui se passe en mémoire:$grep bonjour <strong>de</strong>mo.txt$grep toto <strong>de</strong>mo.docPID 103 PID 104Co<strong>de</strong> Co<strong>de</strong> grep Co<strong>de</strong>Donnéess=bonjourDonnéess=totoBibliothèque Bibliothèque BibliothèqueFichiersFichiers<strong>de</strong>mo.txt<strong>de</strong>mo.docSi nous exécutons un ps -af on aura :UID PID PPID C STIME TTY TIME CMDtrac 103 96 0 15:24 tty2 00:00:00 greptruc 104 92 0 15:24 tty4 00:00:00 grepOn peut avoir <strong>les</strong> processus système avec la comman<strong>de</strong> ps -axLe répertoire /proc fournit aussi <strong>de</strong>s informations essentiel<strong>les</strong> <strong>sur</strong> <strong>les</strong> processus. (Linux Magazine N°18 Juin2000 p24)2°) Les appels <strong>systèmes</strong>• Création <strong>de</strong> processus : pid_t fork(void) #inclu<strong>de</strong> • Terminaison void _exit(int status)void exit(int status)• Attente <strong>de</strong> terminaison <strong>de</strong>processus filsExemple <strong>de</strong> programme :pid_t wait(int *statusp)pid_t wait_pid(pid_t pid,int*statusp, int options)#inclu<strong>de</strong> #inclu<strong>de</strong> #inclu<strong>de</strong>#inclu<strong>de</strong> #inclu<strong>de</strong> #inclu<strong>de</strong> int i;main() {pid_t pid;i=1;pid=fork();if (pid==-1)perror("fork");else if (pid==0) {printf("Je suis le processus fils : pid %d\n",pid);sleep(2);10 /98 S. Moutou : Cours

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!