The UNIX Operating System
- kernel + shell + system calls
- provides access to H/W resources of computer (kernel)
- manages memory and CPU (kernel)
- provides command-line interface to services (the shell)
- provides method-call interface to services (system calls)
Also: libraries which provide a higher-level view/API
than do the system calls. (API = application programming interface)
Overview of UNIX portion of course
We'll (try to) cover:
- basic concepts and terminology
- files and directories
- processes
- interprocess communication
- - signals and signal handling
- - pipes
- - shared memory, messages, semaphores
- X terminal i/o
- - sockets
- standard i/o library
Basics: Files and Processes
- info stored in files
- while files have logical structure to programs that create, use them, at UNIX level, they are just a sequence of bytes (no record terminators, no file terminators, no special file types)
- names < 256 characters ( < 14 to be backward compatible)
Directories, pathnames
- directories have hierarchical, tree-like structure
- each directory can contain files and subdirectories
- full names of UNIX files are pathnames -- include directories
Example:
/users/faculty/eileen/intro.notes (absolute pathname)
if _current working directory_ is /users/faculty/eileen,
then can use
intro.notes (relative pathname)
if _current working directory_ is /users/faculty
then can use
eileen/intro.notes (also a relative pathname)
Ownership, permissions
- each file has an owner, that owner is a member of a _group_
- each file has 3 sets of permissions: read/write/execute
one set for owner, one set for group, one set for public
Devices
UNIX treats devices like files. That is, a filname exists
that represents a device like a keyboard or printer. To
write to the printer, you can just write to the file that
represents it...
for example:
cat fileX > /dev/rmt0
causes the conents of fileX to be written to the tape drive
associated with the rmt0 file in the /dev directory
Processes
process = instance of an executing program
When you type:
> ls
at the command line, the shell process creates a process to run ls.
UNIX is multitasking -- more than one process can run at the same
time. (multiple processes share the CPU)
IPC - Interprocess communication
mechanisms that allow processes to send each other info.
Methods differ in type/amount of info, number of processes,
whether processes need to exist at the same time, be on
same machine, etc.
pipes - output of one program is input of another
shell supports this:
> ls | more
output of the ls program is input to the more program
> ls | grep notes | more
output of the ls program is input to the grep program
notes is a command line parameter to grep
output of grep is input to more
signals
processes that exist at same time on same machine can send integer signals
shared memory
processes that exist at same time can share variables
semaphores
to control access to shared memory
sockets
processes that exist at same time on same or different machines
can communicate arbitrary info
System calls and library functions
In this course, you'll learn about the "system call interface"
kernel
memory resident program, deals with process scheduling and i/o control
system calls
the interface to the kernel and the resources it controls. Are
invoked like library subroutines (but typically more efficient, lower level,
run in 'kernel mode' rather than 'user mode'). Library routines are a
layer between user code and system calls.
Example:
library call:
nread = fread(inputbuf, OBJSIZE, numerobjs, fileptr);
system call:
nread = read(filedes, inputbuf, BUFSIZE)