Lecture: OS organization

class structure

overview

programming interface

example: hello

$ strace -f -- echo hello

output:

execve("/usr/bin/echo", ["echo", "hello"], [/* 43 vars */]) = 0
...
write(1, "hello\n", 6)                  = 6
...
exit_group(0)                           = ?

example: uptime

$ strace -- uptime

output:

execve("/usr/bin/uptime", ["uptime"], [/* 43 vars */]) = 0
...
open("/proc/uptime", O_RDONLY)          = 3
lseek(3, 0, SEEK_SET)                   = 0
read(3, "8827716.99 421503180.64\n", 8191) = 24
...
write(1, " 15:37:50 up 102 days,  4:08,  8"..., 72) = 72
...
exit_group(0)                                          = ?

example: sh and uptime

$ strace -f -- sh -c uptime

output:

execve("/bin/sh", ["sh", "-c", "uptime"], [/* 43 vars */]) = 0
...
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f2813f27850) = 19224
strace: Process 19224 attached
[pid 19223] wait4(-1,  <unfinished ...>
[pid 19224] execve("/usr/bin/uptime", ["uptime"], /* 43 vars */) = 0
...
[pid 19224] exit_group(0)               = ?
[pid 19224] +++ exited with 0 +++
<... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 19224
...
exit_group(0)                           = ?
$ strace -f -- sh -c "uptime && true"

exercises

draw the system calls for the following:

$ uptime > file
$ uptime | tr '[a-z]' '[A-Z]'

hints: try strace -f -- sh -c "<cmd>".

summary

isolation

kernel-user split