130 likes | 266 Vues
Workbook 9: Managing Processes. Chapter 1: An introduction to processes. A process is a program in execution. Defined by a process control block, which includes: Process ID Process priority Process state Location of program in memory Address of next instruction to be executed
E N D
Chapter 1: An introduction to processes • A process is a program in execution. • Defined by a process control block, which includes: • Process ID • Process priority • Process state • Location of program in memory • Address of next instruction to be executed • List of resources held by the process • Etc, etc, etc
Chapter 2: Process States in Linux • Creating a process: • The parent process duplicates itself (forking) • The child process runs a new program (execing) • Typically, the parent process waits for the child to die, as when executing a command in bash, though there are exceptions.
Chapter 2: Process States in Linux (cont) • Processes can be in one of five states: • R: Runnable • S: Voluntary Sleep • D: Involuntary Sleep • T: Stopped (Suspended) Processes • Z: Zombie
Chapter 3: Process scheduling in Linux • Every process has a numerical priority associated with it. • The lower the number, the higher the priority. • This priority can be adjusted up or down with the nice command. • All running processes get a chance to go during a scheduling “epoch”; higher priority processes get more time. • At the end of the epoch, processes are re-evaluated.
Chapter 4: Sending signals • Signals can be sent to a process, for various reasons: • Hardware error, e.g. divide by zero • Software conditions, e.g. child dies or window resized • Terminal interrupts (CTRL-C and CTRL-Z) • Processes can send signals to other processes for various reasons, if owned by same user
Chapter 5: Job control • Jobs can be run in foreground (can’t do anything else) or background (can do other other things). • From command line, finishing with “&” runs the command in the background. • Foreground jobs can be interrupted with CTRL-Z, then resumed with fg or run in the background with bg. • A list of running jobs can be generated with the jobs command.
Chapter 6: Scheduling Delayed Tasks • Programs can be scheduled to run with the at command. • A list of scheduled commands can be viewed with the atq command.
Chapter 7: Scheduling Periodic Tasks • The cron command can be used to schedule tasks to run at a specific time and day of the week or month. • cron tasks are defined in the cron table. • The cron table is edited with the crontab command.
Conclusion • Like other computer systems, Linux provides facilities for managing processes. These are text-based, as per usual. • Processes can be in a number of different states, depending on what's happening.
Conclusion (cont) • Processes are scheduled according to priority, and a process's priority can be set or changed with nice and renice. • Processes can be in a number of different states, depending on what's happening.
Conclusion (cont) • Processes can communicate with each other via signals. • A number of jobs can be run at a time from the command line, if they are put in the background. • Processes can be run at set times with at and crontab.