Download presentation
Presentation is loading. Please wait.
Published byGrethe Mørk Modified over 5 years ago
1
System Calls System calls are the user API to the OS
CSCE 410/611 System calls are the user API to the OS System calls are not function calls! How are system calls invoked? Why are system calls implemented this way? System Calls
2
Operating System Interfaces: System Calls
CSCE 410/611 Operating System Interfaces: System Calls applications programs/ processes system call system call interface scheduler file system kernel memory manager etc. device drivers hardware System Calls
3
Types of System Calls File Management Device Management
CSCE 410/611 Types of System Calls File Management create file, delete file open, close read, write, reposition get/set file attributes Process Control load execute end, abort create process terminate process get/set process attributes wait for time, wait event, signal event allocate, free memory Device Management request device, release device read, write, reposition get/set device attributes logically attach or detach devices Information Maintenance get/set time or date get/set system data get/set process, file, or device attributes Communication create, delete communication connection send, receive messages transfer status information attach or detach remote devices System Calls
4
System Calls – They look like Functions ...
CSCE 410/611 System Calls – They look like Functions ... #include<unistd.h> int main(void) { write(1, "Hello, world\n", 13); return 0; } System Calls
5
... but they are not! Making System Calls in 32-bit Linux
CSCE 410/611 ... but they are not! Making System Calls in 32-bit Linux load system call number in register eax. load arguments to system call in registers ebx, exc, edx, esi, edi, ebp invoke software interrupt: int 0x80 Returned values are stored in eax. 64-bit Linux? same but different different registers different numbers syscall instruction System Calls
6
CSCE 410/611 System Call Numbers syscalls.kernelgrok.com System Calls
7
System Calls - Example Using the Unix Standard Library
8
System Calls - Example Using 32-bit Linux System Calls
9
System Calls - Example Using 64-bit Linux System Calls
10
System Calls are Expensive!
CSCE 410/611 System Calls are Expensive! Software interrupts are expensive! Cost of context switch (saving/restoring registers) Caches are stale TLBs CPU pipelines Compiler optimization not possible. System Calls
11
Why Interrupts or syscall?
CSCE 410/611 Why Interrupts or syscall? Reason 1: Can load user program into memory without knowing exact address of system functions. Reason 2: Separation of address space, including stacks: user stack and kernel stack. Reason 3: Automatic change to supervisor mode. Reason 4: Can control access to kernel by masking interrupts. System Calls
12
Reason 4: Mutual Exclusion in Kernel
CSCE 410/611 Reason 4: Mutual Exclusion in Kernel user space Thread 2 Thread 1 Thread 1 Thread 1 interrupt! system call kernel space Thread 1 executing in kernel. Interrupts are masked. Thread 2 can not enter kernel because of masked interrupts unmasks interrupt and returns rti System Calls
13
Summary: System Calls System calls are the OS API
CSCE 410/611 System calls are the OS API They look like function calls... ... but they are not! They are implemented using software interrupts (or variations thereof) Why are they implemented this way? System Calls
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.