- abstraction of running program
- supports ability to have psuedo-concurrent operation
- In a uniprogramming model, no notion of a process is needed, because you only have one at all times
- program counter
- registers
let divisible n m = match n mod m with 0 -> true | _ -> false | |
let crackle_pop n = | |
let n_is_divisible_by = divisible n in | |
match (n_is_divisible_by 3, n_is_divisible_by 5) with | |
| true, true -> "CracklePop" | |
| true, _ -> "Crackle" | |
| _, true -> "Pop" | |
| _ -> string_of_int n |
The interface between user programs and the operating system is primarily about dealing with abstractions
a syscall library is provided in many languages to make system calls from the language
making a system call is a special type of procedure call except that syscalls enter kernel while procedure calls do not
TRAP instruction jumps to a fixed address, then this piece of code examines the syscall number and dispatches to the appropriate syscall handler (via id-handler indexed table)
Once syscall is completed its work, control might be returned to the user space procedure, and the stack is cleaned up
N.B. If the syscall is blocking, it will not return control to the user space procedure! ex. is a keyboard watiing for input
#include <stdio.h> | |
#include <unistd.h> | |
#include <sys/wait.h> | |
#include <fcntl.h> | |
int main() { | |
int pipefd[2]; | |
pipe(pipefd); |