Lektion 1 Flashcards
In X Windowing system, the application is a
client
In X Windowing system, the GUI machine is a
server
GNU means
GNU is Not Unix
GNU’s father was
Richard Stallman
GNU’s vision
Open and free OS
Unix was originally in internal project at
AT&T
Unix was originally written in
assembly
Unix was later ported to
C
Unix in C portability
10% had to be rewritten in assembly
Main variants of Unix
BSD-Unix and System V
AT&T’s Unix variant
System V
System V was developed by
AT&T
BSD was developed by
Berkley University
Sun Microsystems’ Unix variant
SunOS and Solaris
SunOS developed by
Sun
Solaris developed by
Sun
HPUX developed by
HP
AIX developed by
IBM
GPL
General Public License
copyleft
opposite of copyright
FSF
Free Software Foundation
Linus Torvald presented a Unix compatible kernel in
1991
What we call Linux, is really named
GNU/Linux
Linux is not really an OS, but
a kernel
XNU
kernel of iOS
Kernel of iOS is
XNU
XNU is based on
Mach, BSD
a “terminal” is a
command window
A terminal runs
a separate shell program
Default Linux shell program
bash
bash
gnu Bourne Again SHell
Executed at login
~/.bash_profile
executed at terminal start
~/.bashrc
~
my home library
my home library
~
~/.bash_profile
at login
~/.bashrc
at terminal start
apropos
find man page of subject
bash file extension
.sh
file header to indicate bash script
!/bin/bash
how to type ~
AltGr+ð SPACE
see kernel version
uname -r
see operating system
hostnamectl
Tell bash to wait for the application it started to end
no & at the end of the command
Tell bash to start a background application, and go on
& at the end of the command
show the path
echo $PATH
show path on separate lines
echo “${PATH//:/$’\n’}”
run a make file to build a program
make
stdio.h : no such file or directory
sudo apt-get install build-essential
stderr
default: terminal
stdout
default: terminal
fprintf(stderr,”…”)
print to both stdout and stderr, but only once if they are the same.
Asynchronous operation
events happen at
unpredictable times and in an unpredictable order
Concurrency
sharing of resources in the same time frame
quantum
CPU time allocated to a process before it has to let
another process run
context-switch time
the time it takes to switch from executing one process to another
Timesharing
the illusion that several processes execute simultaneously
interruption
hardware flag, checked at each instruction cycle
An event is asynchronous to an entity
if the time at which it occurs is not determined by that
entity
timer
generates an interrupt after a specified interval of time (or cycles?)
signal
software notification of an event
stack canary
Known random value that must be overwritten to overwrite the return address
A program whose execution has started but
has not yet terminated
is a process
Each source file is compiled into
an object file
Object files are
linked with libraries to produce an executable module
At ececution, the executable module
is copied into a program image in main memory
static storage
exists for the life of the process
automatic storage
allocated when execution enters a block and deallocated when it leaves
Interactions between processes
- files
- pipes
- shared memory
- network
context switch
execution switches from one process to the next
Threads
- execute within the same process
- avoid context switches
- share code and data
execution stack
a.k.a. call stack
activation record
element on the call stack.
return address, parameters, register values to be reset on return
void perror(const char *s);
Output to standard error gt he string and the message for the current errno
char *strerror(int errnum)
- returns a pointer to the system error message corresponding to the error code
- produce informative messages
- use it with functions that return error codes
directly without setting errno - may change the static errno! (Not its parameter.) You should save and restore errno if you need to use it again!
- the returned string may be overwritten by later calls.
restarting library
- restart.h
- r_*, eg restartng close is r_close
a function that allocates memory should
either free the memory
or make a pointer available to the calling program
Standard approaches to handling errors in UNIX
- Print out an error message and exit the program (only in main).
- Return –1 or NULL, and set an error indicator such as errno.
- Return an error code.
conditional compilation for error messages in functions
#define DEBUG /* comment this line out for no error messages */ int myfun(int x) { x++; #ifdef DEBUG fprintf(stderr, "The current value of x is %d\n", x); #endif }
Alternative:
cc -DDEBUG …
om the compiler line
restrict
require that ‘restricted’ parameters not occupy the same memory (typically because parameters are changed by the function)