NTPD – Network Time Protocol Daemon
Mittels NTPD können wir von einem gewünschten Server eine Zeit abfragen
Important
A Server ion GErmany could be : http://ptbtime1.ptb.de/
stratum : trust-worthiness of that servers data
Stratum Concept

Important
Beispiel ==MacOS== mittels
sntp:
sntp -d[ntp1.rz.uni-saarland.de](http://ntp1.rz.uni-saarland.de/)[ntp2.rz.uni-saarland.de](http://ntp2.rz.uni-saarland.de/)[ntp3.rz.uni-saarland.de](http://ntp3.rz.uni-saarland.de/)
Shell Programming
-
scripts start with
#!/bin/bash -
call commands, programs, shell scripts
-
using control structures
-
environment variables
-
setting vars: VAR=value
-
reading vars: $value
-
parameters 1,…$9
-
return / exit value $?
-
all variables are strings
may in conditions be interpreted as an integer
Conditions in Shell Programming : The Test command

Controll Structures
1. for ... do ... done
2. for ... in ... do ... done
3. while ... do ... done
4. until ... do ... done
5. if ... then ... else ... fi, see also elif
6. case ... esac
there is a break statement to leave loopsShell Functions
#!/bin/sh
do_something()
{
if test -e $1 ; then
echo file $1 exists
return 0
else
echo file $1 "doesn’t" exist
return 1
fi
}
do_something /etc/passwd
do_something /etc/nothing
exit 0 # return sucessfullyImportant
with
attimed scripts are possible,crontab -eis used for periodically running scripts
-
What is a Process ?
A Process is a program currently being executed by a processor
Important
Each process has a unique PID, created at the start
Important
the command
fork( )can be used to create an identical copy of a process.
This copy has the same memory and registers
-
parent process :
fork( )reuturns PID of child -
child process :
fork( )returns 0
Context Switches
Ein Kontext Switch ist ein Wechsel der Aufgabe, entweder nach :
-
Ablauf der Bearbeitungszeit des Prozesses
-
nach einem System Interrupt
Was gemacht wird :
- Speichern der Register des jetztigen Prozesses
- Laden der Register des nächsten Prozesses
Threads
-
Was ist ein Thread ?
Threads sind Aufgaben, welche innerhalb eines Prozesses abgearbeitet werden.
Important
Threads innerhalb eines Prozesses teilen sich den gleichen Speicher (Shared Memory)
-
Warum Threads nutzen ?
-
Threads sind einfach zu erstellen wie neue Prozesse
-
Kontext Wechsel sind schneller → Caches werden verwendet
-
-
Welche Probleme können bei Threads auftreten ?
-
Schreiben / Lesen auf gemeinsamen Speicher ist geblockt → ==DeadLocks==
-
System Call könnten den ganzen Prozess blockieren → Alle Threads blockiert
-
Programming Threads
• pthread create()
creates thread and fills a pthread t struct
attributes (may be NULL)
function pointer (entry point to the thread, param arg)
pointer arg to a self-defined thread data structure
• pthread join()
waits for thread termination
which pthread t
arg is adress of pointer to exit–value of thread
• pthread exit()
terminates the thread
arg is pointer to exit valueScheduler
Which Process is allowed to run ? → WE need a Round-Robin Scheduling algorithm
Priorities can be set by : nice , renice , setpriority( )
Possible Status of a Process [ ps → ==STAT column== ]
| Code | Meaning | Details / Examples |
|---|---|---|
| R | Running | Aktuell auf CPU ausgeführt |
| S | Sleeping (< 20 s) | Kurzschlaf durch sleep(), read(), accept(), … |
| I | Idle / Long Sleeping (≥ 20 s) | Länger inaktiv, z. B. wartend |
| D | Uninterruptible Sleep | Meist durch I/O-Operationen blockiert |
| T | Stopped / Traced | Angehalten oder durch Debugger verfolgt |
| W | Swapped | Aus dem Hauptspeicher ausgelagert |
| Z | Zombie | Beendeter Prozess, dessen Parent den Exit-Status noch nicht abgeholt hat |