Professional Documents
Culture Documents
System calls
• System calls are an operating system’s API
– The set of functions that the operating system exposes to processes
• If you want to the OS to do something, you tell it via a
Operating Systems system call
03r. The system call • Examples
Windows Linux
NtOpenFile open
NtReadFile read
Paul Krzyzanowski
NtCreateProcess fork
Rutgers University
NtGetCurrentProcessorNumber getpid
Spring 2014
February 18, 2014 © 2014 Paul Krzyzanowski 1 February 18, 2014 © 2014 Paul Krzyzanowski 2
What are system calls used for? System calls are made via traps
• Anything to do with: • System calls request operating system services
– Accessing devices – Communicating with other processes • Operating system code executes with the processor running in kernel
– Accessing files – Stopping/starting processes (also known as supervisor or privileged) mode
– Requesting memory – Setting a timer
– Setting/changing access permissions – Privileged mode gives the CPU the rights to:
• Execute special instructions
• You need a system call to: (change interrupt masks, set hardware timers, halt the processor)
• Access specific registers (e.g., private stack pointer)
– Open a file
• Change the memory map
– Get data from the network
• Access regions of memory that have been restricted for kernel access only
– Kill a process • Access the processor’s I/O ports (if the architecture has them)
• You do not need a system call to: • A trap takes has one parameter: index into an Interrupt Vector Table
– Replace data in a string – The table is in memory that only the kernel can access
– Create an object (instance of a class) – All addresses in the table go to well-defined entry points in the OS
– Call a function
February 18, 2014 © 2014 Paul Krzyzanowski 3 February 18, 2014 © 2014 Paul Krzyzanowski 4
February 18, 2014 © 2014 Paul Krzyzanowski 5 February 18, 2014 © 2014 Paul Krzyzanowski 6
February 18, 2014 © 2014 Paul Krzyzanowski 7 February 18, 2014 © 2014 Paul Krzyzanowski 8
February 18, 2014 © 2014 Paul Krzyzanowski 9 February 18, 2014 © 2014 Paul Krzyzanowski 10
The End