Lecture: programming interface
preparation
- read the xv6 book: §0, Operating system interfaces
questions from last lecture
overview
- recap: print to screen via MMIO (
0xb8000
on x86)
- history: punch cards - see Holzmann’s To Code Is Human
- Unix system calls & files - see the readings page
- this lecture will use Linux as an example, via
strace
example: hello
output:
- system calls:
execve
(first), write
, exit_group
(last)
- what’s the first argument of
write
- what’s the relationship between
printf
and write
- what’s the first argument of
exit_group
example: uptime
output:
- system calls:
open
, lseek
, read
, …
- file:
/proc/uptime
- is this a real file on disk?
(source code)
- other pseudo files: e.g., procfs
cat /proc/cpuinfo
cat /proc/iomem
- compare to JOS’s output
example: sh and uptime
output:
- system calls:
clone
(old days: fork
), wait4
- what do they do
- how do they communicate
- child vs parent processes: what are copied/shared
if you don’t see clone
(possibly with old bash), try:
exercises
draw the system calls for the following (you can use strace
but don’t have to):
summary & questions
- system calls (and “files”): why do we need them at all - just library functions?
- guess how
strace
is implemented