Presentation is loading. Please wait.

Presentation is loading. Please wait.

Scis.regis.edu ● CS 468: Advanced UNIX Class 4 Dr. Jesús Borrego Regis University 1.

Similar presentations


Presentation on theme: "Scis.regis.edu ● CS 468: Advanced UNIX Class 4 Dr. Jesús Borrego Regis University 1."— Presentation transcript:

1 scis.regis.edu ● scis@regis.edu CS 468: Advanced UNIX Class 4 Dr. Jesús Borrego Regis University 1

2 Topics Controlling Processes Periodic Processes Process Management Q&A Midterm 2

3

4 Process A running program Used to control resource allocation by the OS When a process is created, a table is made in a Process Table Process consists of address space and memory pages allocated to the process Address space has code, variables, stacks, virtual memory pointers, and other data 4

5 Processes 5 A process can be defined as: a program in execution an instance of a running program the entity that can be assigned to, and executed on, a processor a unit of activity characterized by a single sequential thread of execution, a current state, and an associated set of system resources Source: Operating Systems: Internals and Design Principles (7 th. Ed.) by William Stallings

6 Process data structures Address space map for process Process state Execution priority Resources allocated and in use File descriptors and network ports used Process signal mask Process owner 6

7 Processes 7

8 Threads Created by a fork in a process Inherits from parent Can have multiple threads executing concurrently Multicore and multiprocessor systems benefit multithreading 8

9 Attributes PID – unique process ID PPID – parent PID UID – user ID; who created the process EUID – effective UID – reflects resources the process can have; same as UID in most cases GID – group ID EGID – effective GID Niceness – how the process interacts with others Control terminal – linkages to standard I/O 9

10 Process lifecycle Created with fork Process execution begins with exec Process terminates with a call to exit ▫Provides return code (0 is success) ▫Parent receives return code to acknowledge child’s death If parent dies first, child is “adopted” by init 10

11 Signals Interrupt request for processes Can be used to communicate among processes Can kill, interrupt, or suspend processes Can be originated by kernel when unhandled exceptions occur When received, a handler is called (if handler is defined); otherwise, kernel takes action 11

12

13 Kill signal Used to terminate a process Can be used by normal users to kill their own processes Root access is required for other processes Kill receives a signal, a numeric value (see previous slide) In some systems, killall terminates init – system shutdown 13

14

15

16 Monitoring processes To monitor processes: ps Shows PID, UID, priority, control terminal Can include memory used, CPU utilization, status See example of ps aux on page 131 16

17

18

19

20 Dynamic Monitoring ps captures a snapshot of the system ▫At that particular time top – top processes using the system every 10 seconds (default) topas – AIX version prstat – Solaris version 20

21 /proc File System The /proc directory contains information about the system state The kernel creates the directory Information is organized by subdirectories named by the PID ▫/proc 1 is the init process directory Predefined directories are shown in Table 5.7 (next slide) 21

22

23

24 Tracing signals and system calls Linux provides visibility into a process with strace ▫Shows every system call and every signal received Similar: truss (AIX, Solaris), and tusc (HPUX) Example of strace is shown on page 137 24

25

26 Scheduling Commands 26 To schedule scheduled processes: cron daemon Starts when system boots up and terminates when shutdown Receives configuration files (crontab) with commands and times to execute ▫User crontabs located /var/spool/cron ▫One for root, up to one per user Executes lines with sh

27 crontab File Format 27 #comments Six field line: ▫Minute, hour, day of month, month, weekday (separated by white space) ▫Command (passed to shell in entirety) % represent new lines ▫Command receives characters up to first %

28

29 Time Formats 29 * - wild card Single integers – matches exactly Two integers separated by dash – range Ranges followed by slash and step: ▫1-10/2  1 to 10, in 2 increments Comma separated list of values 35 10 * * 1-3  10:35 am Monday to Wednesday

30

31 crontab Management 31 To create or replace your user’s crontab: crontab filename To check out crontab and edit: crontab -e To list contents of crontab: crontab -l To remove crontab: crontab –r Roots can add username to above

32 Applications of cron 32 Preinstalled: ▫Daily scripts in /etc/cron.daily ▫Weekly scripts in /etc/cron.weekly Reminders: periodic tasks Filesystem cleanup ▫Removing obsolete files Network file synchronization Log file cleanup

33 Process Management 33 Kernel controls process access to RAM and CPU: ▫Scheduler – allocates CPU time to a processes, based on scheduling algorithm ▫Memory Manager – allocates memory space to each process and protects it from external source access

34 CPU Utilization 34

35 Scheduling of processes 35 Source: Operating Systems: Internals and Design Principles (7 th. Ed.) by William Stallings

36 Executable file layout 36 Magic Number and Main Header Section One Header Section Two Header Section One Section Two

37 First Processes PID 0 (sched) – created at boot PID 0 executes fork and exec twice to create processes 1 (init) and 2 (pageout) 37 Process 1 fork/exec process 48 process 12 process 34 fork/exec

38 Process States 38 RunningZombiedRunnableIdle Sleeping Suspended Initialize Signal Exit Wait on Event Occurs Allocated CPU

39 Process Composition Code Area – executable portion of the process Data Area – static data used by process Stack Area – Temporary data User Area – Housekeeping process information Page Tables – Memory management system 39

40 User Area One per process Accessible by the kernel Fields included: ▫Signal handling record ▫File descriptor record ▫CPU access record 40

41 Process Table One entry for each process Created in kernel’s data region Contain: ▫PID and PPID ▫UID and GID ▫Process state ▫Location of code, data, stack, user area ▫Pending signal set 41

42 Midterm 2 hour Take home Due by Friday midnight Email in a Word document to jborrego@regis.edu jborrego@regis.edu 42

43 Questions? 43


Download ppt "Scis.regis.edu ● CS 468: Advanced UNIX Class 4 Dr. Jesús Borrego Regis University 1."

Similar presentations


Ads by Google