A very simple kernel, with priority based scheduling and a file system.
- 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 - seeset_nonblocking
.close
- closes a file descriptor.dup2
- duplicates fd fromold
tonew
.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-blockingfork
- 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. Usesfork
,pipe
,exec
, anddup2
.wait
/waitpid
- both use thewait
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.
All references access March 2017.
- Linux Man-pages. Various. man7.org
- Wait sys call. The Open Group. pubs.opengroup.org
- Exit sys call. The Open Group. pubs.opengroup.org
- POSIX IPC. Oracle. docs.oracle.com
- Linux Interprocess Communications. Goldt. S, Van der Meer. S, Welsh. M. tldp.org
- Interprocess Communication (IPC), Pipes. Marshall, D. Users.cs.cf.ac.uk
- General overview of the Linux file system. Machtelt. G. tldp.org
- Cormen. T, Leiserson. C, Rivest. R, Stein. C. Introduction to Algorithms 3rd Edition, (Massachusetts Institute of Technology, 2009) Heapsort and Priority Queues. pp151-166