1
CS644 week 10:
Review
Syscalls – how you talk to the OS
2
Week 1
Filesystems – how you persist data
(unsynchronized!)
3
Weeks 2 & 3
Filesystem APIs
open(2) – open a file
read(2) – read from a file
write(2) – write to a file
lseek(2) – change read/write position
close(2) – close a file
stat(2) – get file metadata
chmod(2) – change file permissions
mkdir(2) – create a directory
opendir(3) – open a directory
readdir(3) – read a directory entry
rename(2) – move or rename a file
unlink(2) – delete a file
rmdir(2) – delete a directory
flock(2) – lock a file
4
Processes – the basic unit of running code
5
Week 4
Process APIs
getpid(2) – get process ID
getppid(2) – get parent process ID
getuid(2) – get real user ID
getgid(2) – get real group ID
geteuid(2) – get effective user ID
getegid(2) – get effective group ID
fork(2) – split into parent and child process
execve(2) – become a different program
waitpid(2) – wait for child to exit
_exit(2) / exit(3) – exit the process
6
IPC – how processes communicate
with each other
7
Week 5
IPC APIs
pipe2(2) – create a pipe
shm_open(3) – open a shared memory object
shm_unlink(3) – delete a shm object
mmap(2) – map a (shared) memory region
sem_open(3) – open a semaphore
sem_wait(3) – wait on a semaphore
sem_post(3) – release a semaphore
sem_unlink(3) – delete a semaphore
8
Networking – talk to the outside world
9
Week 6
Networking APIs
socket(2) – create a network socket
getaddrinfo(3) – create an address
bind(2) – bind a server to a socket
listen(2) – listen for new connections
accept(2) – accept a new connection
connect(2) – connect as client
send(2) – send data on a socket
recv(2) – receive data on a socket
10
Multithreading – run code concurrently
11
Week 7
Multithreading APIs
clone(2) – create a thread (low-level)
pthread_create(3) – create a thread
pthread_join(3) – wait for a thread
pthread_exit(3) – exit a thread
pthread_mutex_init(3) – create a mutex
pthread_mutex_lock(3) – lock a mutex
pthread_mutex_unlock(3) – unlock a mutex
pthread_mutex_destroy(3) – delete a mutex
pthread_rwlock_init(3) – create a read/write lock
pthread_rwlock_rdlock(3) – lock a read/write lock for reading
pthread_rwlock_wrlock(3) – lock a read/write lock for writing
pthread_rwlock_unlock(3) – unlock a read/write lock for writing
pthread_rwlock_destroy(3) – delete a read/write lock
12
Signals – asynchronous "notifications"
13
Week 8
Signals APIs
kill(2) – send a signal
sigaction(2) – set action for signal
sigprocmask(2) – get or set signal mask
pause(2) – wait for any signal
sigwait(2) – wait for a signal
sigsuspend(2) – set mask and wait for a signal
14
Advanced I/O – lots of (non-blocking) I/O
at once
15
Week 9
Let's celebrate!
16