Presentation is loading. Please wait.

Presentation is loading. Please wait.

CHAPTER 8 (299-310, 333-345) John Carelli, Instructor Kutztown University carelli@kutztown.edu.

Similar presentations


Presentation on theme: "CHAPTER 8 (299-310, 333-345) John Carelli, Instructor Kutztown University carelli@kutztown.edu."— Presentation transcript:

1 CHAPTER 8 ( , ) John Carelli, Instructor Kutztown University

2 Definition - execution of a command
PID - Process IDentification number Hierarchical structure processes can spawn children (sub-processes) pstree command

3 https://goo.gl/images/381BdN

4 Definition - the lifetime of a user login process
job - a command pipeline (which may be a simple command)  ; - command separator  & - run in the background

5 history - log of past commands
jobs - currently running jobs kill, (stop, in tcsh) - terminate a process fg, bg - move process to for/background ps - list processes top - view top running processes uptime - time system has been running free - report on available memory pstree - show process tree nohup - run command immune to hangups

6 ps command Used to view processes
Unix, BSD, and GNU (long format) options Unix: single dash BSD: no dash GNU double dash Current user’s processes ps ux ps –ly (or ps –F …) All user’s processes ps aux ps –ely Note: these output different information!

7 strace - trace system calls on a command
truss (not implemented) is similar gprof (prof) - compile c/c++ programs with –gp option - run gprof on executable to get profile - see profile.c example

8 fc –l List commands from history fc –e emacs Use emacs to edit and reexecute previous command fc –s <num> Reexecute command number <num> fc –s <old_string> = <new_string> <num> Reexecute command number <num> after changing <old_string> to <new_string>

9 dirs - display directory stack
pushd - push a directory on to stack (and go there) popd - pop a directory from the stack (and go there)

10 Scheduler decides which processes to run and for how long uses preemptive multitasking – system decides (cooperative is the other choice – process “yields”) Memory manager virtual memory system looks like it has more actual memory pages, page tables Magic number embedded near beginning of file – indicates file type file command uses it to identify type fork() system call see fork.c example

11 Data Structure in RAM Contains info about the following: PID PPID (parent) Real and effective UID and GID Process state Location of its code, data, stack and user area List of all pending signals

12 init - last step in boot process (creates id “1”)
fork(), exec() - spawn new processes (see fork.c and doexec.c examples) getty - create terminal session (mingetty) login - login a user Modes User - “normal” user kernel - root

13 Termination status Normal - process runs to normal completion Abnormal - terminated externally (ex: kill -9) wait() - “C” system call - parent suspends … waits for status of child to change - see waitpid.c example Zombie process - terminated, but still in process table - exists so parent can read exit code - can’t kill it with kill command (see zombie.c) Orphan process - parent terminated (intentional or not) - init process becomes parent (see orphan.c)

14 Idle Runnable / Ready Running Zombie Sleeping / Blocked Suspended Exit
To see status codes: ps -o uid,pid,stat,cmd Codes: D Uninterruptible sleep (usually IO) R Running or runnable (on run queue) S Interruptible sleep T Stopped Z Defunct ("zombie") process Additional info: < high-priority (not nice to other users) N low-priority (nice to other users) L has pages locked into memory (for IO) s is a session leader + is in the foreground process group Idle Runnable / Ready Running Zombie Sleeping / Blocked Suspended Exit

15 User Code area - program instructions Data area - program data Stack area - program stack (manage function calls) User area - housekeeping Kernel area Process Table Page Table

16 Multilevel Priority Queue
scheduling algorithm Process’ s priority processes get a priority number ex: ps -o uid,pid,ppid,pri,ni,cmd Priority computation Nice value (nice, renice -n) 20 is nice, -20 is not, 0 default Context switch save the process state restore it later

17 Pages (stored in memory)
Region table (inode ptrs, page table ptrs, process #’s, …) Page table Modified bit (“dirty bit” – checks for data modification) Referenced bit (set when referenced, periodically cleared) Age (LRU – least recently used) RAM table (paging DS in RAM) Page daemon (paging mgmt. process) Swap space (program moved to disk) Page fault (page not in memory)

18 Delayed Execution crontab run jobs on a schedule
sets up tables for the cron daemon to open editor: crontab –e at execute a command at a specific time output gets mailed to you (via unix mail)

19 Signals and Sockets Assign a signal handler with signal()
Example: timeout.c Interprocess server/client communication via a socket Example: server.c and client.c (with makefile)


Download ppt "CHAPTER 8 (299-310, 333-345) John Carelli, Instructor Kutztown University carelli@kutztown.edu."

Similar presentations


Ads by Google