Content
Process Control
Process control allows us to talk about execution, threads or threads, which are a sequence of tasks chained so small that they can be executed by an operating system
Process model with two states
A process can be in one of two basic states:
- Execution
- No execution
Processes not running
With a single queue of non-running processes, the scheduler would have to traverse it to find a process that is not blocked. FIFO (First-in, First-out) strategy is not used
Two types of non-execution processes:
- Ready to run
- Locked: Expect to complete an I/O operation
Model of five states
- Execution
- Ready
- Locked
- New
- Finished
- Locked/Suspended: The process is in secondary memory waiting for an event
- Ready / Suspended: The process is in secondary memory available for execution
- The process stops its execution
- Branches to execute a signal processing routine (code must be part of the process itself)
- Once the processing routine is executed, follow the execution of the process
- The source can be the operating system or a process
- At POSIX, it is done using the kill service
- Modern process: Unit of resource ownership
- Thread (or light process): Unit or engine running
- Execution
- Ready
- Locked
- Creating/destroying a thread
- When you create a process, you also create a thread
- A thread of a process can create other threads within the same process
- Lock/Unlock
- Reservation-specific resource from the thread
- Processor Logs: counter, battery, status, etc.
- Thread Status: Execution, Ready or Locked
- Address Space: code and data
- Global Variables
- Open files
- Other shared resources
- It takes less time to create/finish a new thread than a process
- It takes less time to switch context between two threads of the same process
- Because threads in the same process share memory and files, they can communicate with each other without invoking the kernel
Processes suspended
The operating system may decide to “evict” a process from main memory and transfer it to disk
Two new states:
Signals and exceptions
Signals and exceptions are the mechanisms that uses an operating system to notify a process of the occurrence of a particular event
The signals are used in POSIX and exceptions are used in Windows
Signals
A signal is the interruption of a process
Receiving the signal:
Sending the signal:
Exceptions
Event that occurs during the execution of a program and that require the execution of a piece of code outside the normal flow of execution
Can be generated by the hardware or the software
Exception handling requires programming language support. For example, in Java:
Threads
A modern process manager separates dynamic execution from static aspects of the computational environment from the process:
A process can contain a single ground thread or several threads of execution
States of a thread
States:
The state suspension belongs to the concept of process
Basic operations related to thread state change:
Processes in a multi-threaded environment
Own information for each thread:
Information shared by all threads in the same process:
Benefits of threads
Facilitates modularity by allowing you to encapsulate each task in a thread independent
Increases job execution speed:
Allows concurrent programming
Process server
A server is a process that is pending receiving work orders that come from other processes (clients)
Once the order is received, it executes it and responds to the customer with the result
Communication between the client process and the server is done through the ports
Daemon
They are booted when you start the system. They are always active and do not die
Running in the background and are not associated with a terminal or login process
They are typically waiting for an event or perform a task periodically
They don't do the work directly: they throw other processes (or threads) to do their homework
Examples: FTP server, web server, ...