Vous êtes sur la page 1sur 41

fork

 

PID UID

fork

 

exec

 

execv

system

 

 

fork

 

IP MAC

TCP

 

C

 

 

atoi sprinf sscanf

 

fork

PID UID

PID

shell Perl

PID

PID

ps

f

C PID

getpid PID

void

C

fork

C

exec

C system

UID Set UID

ID UID

UID

chmod root

UID

0 C UID

getuid

void

Set UID

Set UID chmod + s

fork

fork

PID

PID

if else switch

fork

1

0

PID PID

int void

\

\

\

\

\

main exit

sys/wait.h

wait

wait

for

break

∗∗

∗∗

sleep

time time.h

0h

exec

main

monprog.c monprog

monprog

cp

C argc argv

main argc

1 argv

argv[0]

argv[1], argv[2]

int int char

int

\

execv

execv

execv

exec

execv

int char char

const execv

argv main argv[0]

argv[1], argv[2], etc

!
!

NULL

argc

$PWD

/ /

/home/remy/enseignement/systeme/script1

.c .h

ls

/bin/ls

int

char

execv

fork exec

!
!

execvp

PATH

Set UID

system

system

PATH

PATH

PATH :

PATH

PATH .bashrc

. PATH

PWD

PATH PATH

/usr/local/bin

/usr/bin

PATH

system

system stdlib.h

C fork exec

clear

C

system

PATH

system

rm

rm

A

B

A

root

moprog

root

monprog.c

remy PATH

. . PATH

PATH

.

remy clear

remy monprog root

clear /usr/bin/clear

root

!
!

system execvp

R R

emacs /usr/bin/emacs

∗∗

∗∗

emacs

k

∗ ∗ ∗ C

n

0

i

C

= 1 C

i = 1 i

i

k

n

C

= C

n1 + C n1

1

k

k

C while for

k

n

main main

/tmp

C C

int

int

int void

 

int

void int

\

int void

void int

int void

int

int void

 

int

void int

\

void int

\

void void int int

int void

int void

int

char

ExecAffiche

void int void

void void

 

int int

\

void void void void

int void

 

int

ExecFonction

float

int

double

void void

int

void void void void

int void

 

ctrl C

pthread.h

libpthread.a

void

pthread create

ma fonction thread arg

pthread create

pthread t

pthread create

attributs

NULL

ma f onction t hread

main

pthread join wait

ma fonction thread

pthread join

pthread create

passageparadressed unpointeur

ma fonction thread

void void

 

int int

\

int void

int

int

void

 

\

\

main

void void

 

int

\

void

int void

 

int

void

void

\

fork

pthread mutex t

mutex pthread mutex lock()

stdout

pthread mutex unlock()

A

B A pthread mutex lock() B

B A

B

A

pthread mutex lock()

!
!

pthread mutex unlock()

void void

int void

 

int

void

void void

int int

int

\

\

pthread mutex lock() pthread mutex unlock()

9 4

0 99

∗∗

TypeTableau

x

TypeTableau

0 99

x

1 x

0

∗∗

1

T 1 T 2

T 1 T 2

T 1

T 2

A

∗∗

compt

1 5

∗∗ N

N = 100

double

main 0 100

tableau[0] tableau[99]

tableau[i]