systemcalls (systemaufrufe) nina, helen & nicole proudly present:

26
Systemcalls (Systemaufrufe) Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present: Nina, Helen & Nicole proudly present:

Upload: griselda-zell

Post on 05-Apr-2015

113 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

Systemcalls (Systemaufrufe)Systemcalls (Systemaufrufe)

Nina, Helen & Nicole proudly present: Nina, Helen & Nicole proudly present:

Page 2: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

1. Definitionen

1.1. Interrupt1.1.1. Exception

1.1.2. Hardware-Interrupt1.1.3. Software-Interrupt

1.2. Systemcall1.2.1. Unix –

Schalenmodell1.2.2. Definition

Systemcall

1.2.3. 5 Bereiche

2. Schematischer Ablauf

3. Beispiele

3.1. ausführlich: creat

3.2. weitere Beispiele

Gliederung

Page 3: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

1. Definitionen

1.1. Interrupt1.1.1. Exception

1.1.2. Hardware-Interrupt1.1.3. Software-Interrupt

1.2. Systemcall1.2.1. Unix –

Schalenmodell1.2.2. Definition

Systemcall

1.2.3. 5 Bereiche

2. Schematischer Ablauf

3. Beispiele

3.1. ausführlich: creat

3.2. weitere Beispiele

Gliederung

Page 4: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

Interrupt

= Unterbrechung des aktuellen Prozesses durch CPU

Unterteilung in :

Exception

Hardware – Interrupt

Software – Interrupt

Page 5: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

Hardware – Interrupt

Page 6: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

Software – Interrupt

= gewollte Unterbrechung des laufenden Progammes,

weil Kernel wichtige Funktionen ausführen soll

- Software – Interrupt wird durch prozessortypabhängige

Befehle (Systemcalls) ausgelöst

Page 7: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

1. Definitionen

1.1. Interrupt1.1.1. Exception

1.1.2. Hardware-Interrupt1.1.3. Software-Interrupt

1.2. Systemcall1.2.1. Unix –

Schalenmodell1.2.2. Definition

Systemcall

1.2.3. 5 Bereiche

2. Schematischer Ablauf

3. Beispiele

3.1. ausführlich: creat

3.2. weitere Beispiele

Gliederung

Page 8: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

Anwenderprogramme

Kernel

Hardware

sh

who

a.out

date

wc

grep

ed

vi

ld

as

comp

cpp

nroff

Unix Schalenmodell – Systemstruktur

Systemcalls

SystemmodeSystemmode

UsermodeUsermode

Page 9: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

Systemcalls

= Anfrage an den Kernel

- Programme fordern per Systemcall Dienstleistungen

vom Kernel an

- definiert Schnittstelle zwischen Kernel und

Benutzerprogramm

Page 10: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

5 Bereiche der Systemcalls

1. Prozessverwaltung fork, exit, exec

2. Speicherverwaltung brk, mmap, munmap

3. Dateiverwaltung open, read, write

4. Geräteverwaltung io_ctl

5. Kommunikation kill, pipe

Page 11: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

1. Definitionen

1.1. Interrupt1.1.1. Exception

1.1.2. Hardware-Interrupt1.1.3. Software-Interrupt

1.2. Systemcall1.2.1. Unix –

Schalenmodell1.2.2. Definition

Systemcall

1.2.3. 5 Bereiche

2. Schematischer Ablauf

3. Beispiele

3.1. ausführlich: creat

3.2. weitere Beispiele

Gliederung

Page 12: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

Systemebenen

Prozessor etc.

Benutzerebene

SystemebeneKernel

Hardware

User-Anwendungen

Bibliotheken Benutzerstack

Hardware-Steuerung

PSRMehr-zweck-register

System-stack

Trap

Userm

odeSystem

mode

weitereRegister

Tabel-len

Page 13: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

BENUTZEREBENE - USERMODE

User-Anwendungen Benutzerstack

SYSTEMCALL

creat(name, 0666);

...

204 mode Angabe (Oktal 666)

1b6 Adresse von name

6a Rückkehradresse

Page 14: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

BENUTZEREBENE - USERMODE

Bibliothek Mehrzweckregister

Befehl Nr

exit 1

fork 2

read 3..

.

.

create 8

142

;ASM.CODEBEGINN MOV MOV JSR JMP . . . . .

…58

7e

80

13c

146

8

TRAP

SYSTEMEBENE - SYSTEMMODE

Page 15: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

BENUTZEREBENE - USERMODE

SYSTEMEBENE - SYSTEMMODE

TRAP

Sof

twar

eint

erru

pt

PSR0 15

OF DF IF TF SF ZF AF PF CF

1

Page 16: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

SYSTEMEBENE - SYSTEMMODE

142

…58

7e

80

13c

146

8

MehrzweckregisterTabelleRegister

U-Bereich

Benutzerstack...

204

1b6

6a

BENUTZER-EBENE – USERMODE

01234567891011

funktion0();funktion1();

funktion2();

funktion3();

funktion4();

funktion5();

funktion6();

funktion7();

funktion8();

funktion9();

funktion10();

funktion11();

204

1b6

Page 17: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

SYSTEMEBENE - SYSTEMMODE

Hardware

;Ken Thompson 1969;.STACK 1000H.DATA VARA DW1; VARB DW2;.CODE BEGINN MOV AX,@DATA; MOV AX,VARA; ADD AX,VARB, … END BEGIN;

Prozessor

0 1 011 0 1 00 1 1 101 11 0 010 110 1 0 100

Page 18: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

Register

U-Bereich

204

1b6

Fehlerfeld

Mehrzweckregister

142

58

7e

80

146

8

SYSTEMEBENE - SYSTEMMODE

13c 0

PSR

0 15

OF DF IF TF SF ZF AF PF CF1

0x800CCC6F

CF

1

Page 19: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

BENUTZEREBENE - USERMODE

SYSTEMEBENE - SYSTEMMODE

PSROF DF IF TF SF ZF AF PF CF

Bibliothek

Befehl Nr

exit 1

fork 2

read 3

.

.

.

.

creat 8

;ASM.CODEBEGINN MOV MOV JSR JMP . . . . .

?

User-Anwendungen Benutzerstack

creat(name, 0666);

...

204

1b6

6aI

Returncode = 0

Page 20: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

BENUTZEREBENE - USERMODE

SYSTEMEBENE - SYSTEMMODE

PSROF DF IF TF SF ZF AF PF CF

Bibliothek

Befehl Nr

exit 1

fork 2

read 3

.

.

.

.

creat 8

;ASM.CODEBEGINN MOV MOV JSR JMP . . . . .

?

User-Anwendungen

creat(name, 0666);

?

Returncode = -1

1

Mehrzweckregister

58

7e

80

146

8

13c

142

0x800CCC6F

0x800CCC6Ferrno

-1

Page 21: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

Permission

No such file or directory

No such process

interrupted system call

…No such device

Not a directory

...

File table overflow

Too many open files

Not a typewriter

EPERM

ENOENT

ESRCH

EINTR

ENODEV

ENOTDIR

ENFILE

EMFILE

ENOTTY

1

3

4

19

20

23

24

25

error messageMakroerrno

User-Anwendungen

creat(name, 0666);

BENUTZEREBENE - USERMODE

Returncode = -1

gmake[1]: *** [libswt-gnome-gtk-3063.so] Error 1gmake[1]: Leaving directory`/usr/ports/java/eclipse/work/plugins/org.eclipse.swt/Eclipse SWT PI/gtk/library'gmake: *** [libswt] Error 2

0x800CCC6Ferrno

*** Error code 2

2

Page 22: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

1. Definitionen

1.1. Interrupt1.1.1. Exception

1.1.2. Hardware-Interrupt1.1.3. Software-Interrupt

1.2. Systemcall1.2.1. Unix –

Schalenmodell1.2.2. Definition

Systemcall

1.2.3. 5 Bereiche

2. Schematischer Ablauf

3. Beispiele

3.1. ausführlich: creat

3.2. weitere Beispiele

Gliederung

Page 23: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

char name[]=„file“; main {

int fd;fd = creat(name, 0666);

}

Systemcall creat

Ausschnitt aus C-Programm

Page 24: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

Teil des Assemblercodes für Motorola 68000

Page 25: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

Weitere Beispiele

– open(<dateiname>,<art>)● öffnet eine vorhandene Datei mit angegebener

Benutzungsart

– read(<filehandle>,<puffer>,<puffergröße>)● liest Datei ein, mit angegebener Anzahl an Bytes

– write(<filehandle>,<puffer>,<puffergröße>)● schreibt angegebene Anzahl an Bytes in spezifizierte

Datei

Page 26: Systemcalls (Systemaufrufe) Nina, Helen & Nicole proudly present:

ENDEENDE