| A future simple linux-like (or unix-like) OS -- could theoretically be created with only 4 syscalls: open()
read()
write()
close() Such a theoretical linux-like or unix-like OS would assume quite literally that "everything is a file" -- including the ability to perform all other syscall/API calls/functions via special system files, probably located in /proc and/or /sys and/or other special directories, as other posters have previously alluded to... Also, these 4 syscalls could theoretically be combined into a single syscall -- something like (I'll use a Pascal-like syntax here because it will read easier): FileHandleOrResult = OpenOrReadOrWriteOrClose(FileHandle: Integer; Mode: Integer; pData: Pointer; pDataLen: Integer); if Mode = 1 then open(); if Mode = 2 then read(); if Mode = 3 then write(); if Mode = 4 then close(); FileHandle is the handle for the file IF we have one; that's for read() write() and close() -- for open() it could be -1, or whatever... Mode is the mode, as previously enumerated. pData is a pointer to a pre-allocated data buffer, the data to read or write, or the full filename when opening... (And of course, the OS could overwrite it with text strings of any error messages that occur... if errors should occur...) pDataLen is the size of that buffer in bytes. When the Mode is open(), pData contains a string of the path and file to open. When Mode is read(), pData is read to, that is, overwritten. When Mode is write(), pData is used to write from. All in all, pretty simple, pretty straightforward... A "one syscall Linux or Unix (or Linux-like or Unix-like) operating system", if you will... for simplicity and understanding! (Andrew Tannenbaum would be pleased!) Related: "One-instruction set computer" (OISC): https://en.wikipedia.org/wiki/One-instruction_set_computer |