Courses/Computer Science/CPSC 457.F2013/Lecture Notes/SystemCalls
We will work from our previous discussion of x86 assembly language programming and see how system calls are made (i.e., their calling convention on x86/Linux), how they are defined, how they can be traced, and how they differ from "normal" function calls.
- Slides: http://www.cpsc.ucalgary.ca/~locasto/teaching/2013/CPSC457-Fall/talks/syscalls.pdf
- A blog entry (with pictures) I wrote about today's lesson: http://mlocasto.blogspot.ca/2013/09/os-class-session-on-system-calls.html
We saw how we could talk directly to the kernel via the syscall interface
- now let's write a program using write(2)
- compare this with our assembly version mywrite.asm
- what is the nature of this interface? (combined API and privilege transition mechanism)
- where are the parts documented?
- manual pages for syscall definitions (syntax and semantics)
- show locations of syscall number definitions: /usr/include/asm/unistd_32.h
- what is the actual mechanism?
- trace the ``control flow of making a system call
- phrack article on IDT: http://www.phrack.com/issues.html?issue=59&id=4&mode=txt
Links to kernel code:
- x86_64 syscall table data structure declaration: http://lxr.cpsc.ucalgary.ca/lxr/#linux/arch/x86/kernel/syscall_64.c
- each architecture is free to define its own system call numbers, see, e.g., Itanium (IA64): http://lxr.cpsc.ucalgary.ca/lxr/#linux+v2.6.32/arch/ia64/include/asm/unistd.h
- MOS: 1.6: System Calls (you should have read this already)
- LKD: Chapter 5. System Calls (this describes how to add a system call to your OS, something you'll have an opportunity to practice in your tutorials later and in HW3)