On this page:
dos-boot
dos-syscall
tcons
dos-test

1 DOS: bare-bones kernel

 (require dos) package: dos

dos provides a bare-bones kernel with no assumptions on what system calls are possible or what the kernel state is. A simple example is included in the source.

procedure

(dos-boot + cur ps zero)  state?

  + : (-> state? state? state?)
  cur : state?
  ps : (treeof (-> state? state?))
  zero : state?
Calls each process in ps (which is a cons-tree of process functions) with cur and expects that either (a) a new state or (b) the process will call dos-syscall and construct a new state. The resulting states are combined using +. Assumes that state?, +, and zero form a monoid, i.e., that states can be combined in any order and (+ a zero) is the same as a.

procedure

(dos-syscall k->state)  state?

  k->state : (-> continuation? state?)
Calls k->state with the current continuation and expects it to return a state that will be delivered to dos-boot. Returns the cur state that dos-boot is called with if the continuation is included in dos-boot’s ps argument.

procedure

(tcons left right)  any/c

  left : any/c
  right : any/c
Returns a cons-tree such that if left or right are null then a cons is not allocated.

This function is useful for constructing arguments to dos-boot’s ps argument efficiently.

procedure

(dos-test cur p)  state?

  cur : state?
  p : (-> state? state?)
Runs the process p with the cur state and returns the state that it returns or constructs with dos-syscall.