Sistemi Operativi
Danilo Bruschi Mattia Monga
System call in MINIX
1
Sistemi Operativi 1
Mattia Monga
Dip. di Informatica e Comunicazione Universit` a degli Studi di Milano, Italia
mattia.monga@unimi.it
22 aprile 2008
1 2008 M. Monga. Creative Commons Attribuzione-Condividi allo stesso modo 2.5 Italia License.c http://creativecommons.org/licenses/by- sa/2.5/it/. Immagini tratte da [?] e da Wikipedia.
Sistemi Operativi
Danilo Bruschi Mattia Monga
System call in MINIX
Lezione XIX: System call in MINIX
Sistemi Operativi
Danilo Bruschi Mattia Monga
System call in MINIX
343
Servizi di sistema
I servizi di sistema sono l’interfaccia tra le applicazioni ed il sistema operativo. Permettono lo svolgimento di operazioni che coinvolgono dispositivi o strutture di memoria gestite dal sistema operativo in maniera controllata. In MINIX:
API POSIX (Portable Operating System Interface), tramite librerie C
messaggi di processi User ai Server Kernel call
messaggi di processi Server o Driver al System Task
Sistemi Operativi
Danilo Bruschi Mattia Monga
System call in MINIX
Kernel call
Sistemi Operativi
Danilo Bruschi Mattia Monga
System call in MINIX
345
Il flusso di una system call POSIX (user)
1
u.c:user if (fork() == 0) /∗... ∗/
2
lib/syscall/fork.s:user fork: jmp fork
3
lib/posix/ fork.c:user syscall(PM PROC NR, FORK, &m)
4
lib/other/syscall.c:user
msgptr−>m type = syscallnr; status = sendrec(who, msgptr);
5
lib/lib/i386/rts/ ipc.s:user
1
mov eax, SRC DST(ebp)
2
mov ebx, MESSAGE(ebp)
3
mov ecx, SENDREC
4
int 33
Sistemi Operativi
Danilo Bruschi Mattia Monga
System call in MINIX
Il flusso di una system call POSIX (kernel)
1
kernel/protect.c:kernel
{s call, SYS386 VECTOR, USER PRIVILEGE }, /∗33: 386 system call ∗/
2
kernel/mpx386.s:kernel
1 s call:
2 ; ...
3 push edx ; event set or flags bit map 4 push ebx ; pointer to user message 5 push eax ; PM PROC NR 6 push ecx ; SENDREC
7 call sys call ; sys call(call nr, src dst, m ptr, bit map)
3
kernel/proc.c:kernel
1 switch(function) { 2 case SENDREC:
3 /∗ fall through ∗/
4 case SEND:
5 /∗ caller USER, src dst PM PROC NR ∗/
6 result = mini send(caller ptr, src dst e, m ptr, flags);
Sistemi Operativi
Danilo Bruschi Mattia Monga
System call in MINIX
347
Il flusso di una system call POSIX (PM)
1
server/pm/main.c:PM server result = (∗call vec[call nr])();
2
server/pm/table.c:PM server
1
int (∗call vec[NCALLS]), (void) ) = {
2
/∗ ... ∗/
3
do fork /∗ 2 = fork ∗/
4
/∗ ... ∗/
5
}
3
server/pm/forkexit.c:PM server sys fork(who, child nr);
4
lib/syslib/sys fork.c:PM server
r = taskcall(SYSTASK, SYS FORK, &m);
5
lib/sysutil/taskcall.c:PM server
msgptr−>m type = syscallnr; status = sendrec(who, msgptr);
Sistemi Operativi
Danilo Bruschi Mattia Monga
System call in MINIX
Il flusso di una system call POSIX (kernel)
1
kernel/mpx386.s:kernel
1 s call:
2 ; ...
3 push edx ; event set or flags bit map 4 push ebx ; pointer to user message 5 push eax ; PM PROC NR 6 push ecx ; SENDREC
7 call sys call ; sys call(call nr, src dst, m ptr, bit map)
2
kernel/proc.c:kernel
1 switch(function) { 2 case SENDREC:
3 /∗ fall through ∗/
4 case SEND:
5 /∗ caller PM PROC NR, src dst SYSTASK ∗/
6 result = mini send(caller ptr, src dst e, m ptr, flags);
7 case RECEIVE:
8 /∗ caller PM PROC NR, src dst SYSTASK ∗/
Sistemi Operativi
Danilo Bruschi Mattia Monga
System call in MINIX
349
Il flusso di una system call POSIX (System)
1
kernel/system.c:System Task result = (∗call vec[call nr])();
2
server/system.c:System Task map(SYS FORK, do fork);
3
server/system/do fork.c:System Task
DO (the kernel part of) FORK!
4
Completa i con i reply
Sistemi Operativi
Danilo Bruschi Mattia Monga
System call in MINIX