Lecture: programming interface
Preparation
- read the xv6 book: §0, Operating system interfaces
Questions from yesterday
- how to set up
PATH
on attu
- how to do the labs on my Mac
- follow the tools guide
- keep homebrew up to date & reinstall packages if some are incomplete
- we are going to grade on Linux, so be sure to test your solutions there
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