Skip to content

Instantly share code, notes, and snippets.

@rubenwardy
Last active June 19, 2017 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubenwardy/a6c70449397a2e4624a84a0c7907d07f to your computer and use it in GitHub Desktop.
Save rubenwardy/a6c70449397a2e4624a84a0c7907d07f to your computer and use it in GitHub Desktop.

Ruben's Kernel (Rubix?)

A very simple kernel, with priority based scheduling and a file system.

Features

  • SYS Calls
    • yield - ends the current time slice.
    • write - writes to an open file descriptor.
    • read - reads from an file descriptor. Returns length of read, 0 on EOF. May blocking - see set_nonblocking.
    • close - closes a file descriptor.
    • dup2 - duplicates fd from old to new. new is closed if it already exists.
    • pipe - creates a pipe. fd[0] is read, fd[1] is write.
    • fopen - open file. Not quite POSIX, as it's non-blocking
    • fork - clones process. Return value is 0 if child, PID of child if parent, -1 if error.
    • exec - replaces the process with another program. PID is kept. Stack and FDs (except in/out/err) are destroyed.
    • exit - exits with exit code.
    • wait - waits for a child program to exit, and gives exit code.
    • kill - sends a kill signal to a process. Killed processes will not return an exit code. signal is not yet implemented.
    • setpriority - set priority of child process.
    • set_nonblocking - is not POSIX, unfortunately. Set pipe non-blocking.
  • LibC help functions
    • popen - opens a process and returns a FD. Uses fork, pipe, exec, and dup2.
    • wait/waitpid - both use the wait syscall.
  • Processe
    • time slicing - timer based timer slices.
    • priority-based - priority(P) = priority_base(P) + slices_since_last_ran(P)
    • blocked queue - for processes waiting for a process or file resource.
    • process ownership - processes have a parent, which can kill/wait them.
    • process groups - a limited type of process group, where all processes that share a parent and the parent itself are in a group.
  • Files
    • FiDes - File descriptor. Interacted with using function pointers. Can be blocking or not.
    • pipe - Pointed to by a FD.
    • in/out/err - these are "files" too!
    • filesystem - Files are limited to 256 bytes, maximum of 10 files.

References

All references access March 2017.

Online

Print

  • Cormen. T, Leiserson. C, Rivest. R, Stein. C. Introduction to Algorithms 3rd Edition, (Massachusetts Institute of Technology, 2009) Heapsort and Priority Queues. pp151-166
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment