Commit 2db61aa

mo khan <mo@mokhan.ca>
2021-02-15 20:40:30
add notes on chapter 2
1 parent 5917f6b
Changed files (1)
doc
doc/2.md
@@ -45,3 +45,125 @@ services for ensuring efficient operation:
   * authentication
 
 ## User Operating-System Interface
+
+### Command Interpreters
+
+Some operating systems include a command interpreter in the kernel.
+Others, such as WIndows and UNIX, treat the command interpreter as a special program
+that is running when a job is initated or when a user first logs on.
+
+On systems with multiple command interpreters to choose from, the interpreters are
+known as shells. For example:
+
+* sh: Bourne shell
+* csh: C shell
+* bash: Bourne-Again shell
+* ksh: Korn shell
+* zsh: Z shell
+
+The main function of the command interpreter is to get and execute the next user-specified command.
+Many commands will manipulate files:
+
+* create
+* delete
+* list
+* print
+* copy
+* execute
+
+These can be implemented in two general ways:
+
+1. the command interpreter has the code to execute the command: direct system calls
+2. system programs: the interpreter uses the command to do the work.
+
+The second approach allows programmers to add new commands to the system. The command
+interpreter can be small and delegate to system programs to do the work and extend it.
+
+### Graphical User Interfaces (GUI)
+
+Uses a mouse-based window and menu system characterized by a desktop metaphor.
+The user user moves the mouse to position the pointer on images, icons, files,
+directories, programs and can invoke it with a mouse click.
+
+GUI's first appeared due in part to research taking place in the early 1970's at Xerox PARC.
+The first GUI appeared on the Xerox Alto computer in 1973. However, graphical interfaces became
+more widespread with the advent of Apple Macintosh computers in the 1980s.
+
+The UI for macOS has undergone many changes but most significant being the adoption of the `Aqua`
+interface that appeared with macOS 10.
+
+Microsoft's first version of Windows - Version 1.0 - was based on the addition of a GUI interface
+to the MS-DOS operating system.
+
+Smartphones and handheld tablets use a touchscreen interface. Users interact using gestures on the touchscreen.
+
+UNIX systems have been dominated by command-line interfaces.
+GUI interfaces are:
+
+* Common Desktop Environment (CDE)
+* X-Windows ssytems
+* K Desktop Environment (KDE)
+* GNOME desktop by the GNU project
+
+Both KDE and GNOME run on Linux and various UNIX systems and are available under open-source licenses.
+
+## System Calls
+
+System calls provide an interface to the services made available by an operating system.
+These calls are generally available as routines written in C an C++.
+
+Systems execute thousands of system calls per second. Developers design programs according to an
+application programming interface (API). The API specifies a set of functions that are available
+to an application programmer, including parameters that are passed to each function and the return
+values the programmer can expect.
+
+Common API's are:
+
+* Windows API for MS Windows
+* POSIX API for POSIX-based systems (UNIX, Linux, macOS)
+* Java API for programs that run on the JVM.
+
+API's are accessed via a library of code provided by the operating system.
+In the case of UNIX and Linux for programs written in the C language, the library
+is called `libc`. Each operating system has it's own name for each system call.
+
+The functions that make up the API typically invoke the actual system calls on behalf of the
+application programmer.
+
+Example of API
+
+```c
+#include <unistd.h>
+
+ssize_t read(int fd, void *buf, size_t count);
+```
+
+Advantages of API:
+
+* API's provide portability.
+* system calls are more difficult to work with
+* most programming languages provide a `system-call interface` that serves as a link to system calls made available by the OS.
+* complex details are handled by API rather than application developer.
+
+System call interface:
+
+* a number is associated with each system call
+* the system-call interface maintains a table indexed according to these numbers
+* the system-call interface invokes the intended system call in the operating-system kernel and returns the status of the system call and any return values.
+
+General methods to pass parameters to the operating system:
+
+1. pass parameters in registers
+  * params are stored in a block, or table in memory and the address of the block is passed as a param in a register. (Linux/Solaris way)
+2. params are pushed onto the stack by the program and popped off the stack by the operating system.
+
+Some OS's prefer the block or stack method because it does not limit the # or length of params passed in.
+
+Types of System calls:
+
+* process controll
+* file manipulation
+* device manipulation
+* information maintenance
+* communications
+* protection