First assignment: Deep source Analysis Process Model

Source: Internet
Author: User

This is the homework assigned by the teacher,

What is a process

1. Process is a computer program on a set of data on a running activity, the system is the basic unit of resource allocation and scheduling, is the basis of the operating system structure.

In the early process design-oriented computer architecture, the process is the basic execution entity of the program, and in the contemporary thread-oriented computer architecture, the process is the container of the thread. A program is a description of instructions, data, and its organization, and the process is the entity of the program.

That is, the process is a program with a certain independent function of a data set of a running activity, is the system of resource allocation and scheduling operation of the basic unit.

2. Definition of the process:

Narrowly defined: A process is an instance of a running program;

Generalized definition: A process is a running activity of a program with certain independent functions about a data set. It is the basic unit of the operating system dynamic execution, in the traditional operating system, the process is not only the basic allocation unit, but also the basic execution unit.

3. Features

Dynamic: The essence of the process is the process of a program in a multi-channel program system, the process is dynamic generation, dynamic extinction. Concurrency: Any process can perform its independence concurrently with other processes: The process is a basic unit capable of running independently, but also an independent unit of system allocation of resources and scheduling; Asynchrony: Because of the inter-process constraints, the process has a discontinuity of execution, that is, the process according to their own independent, Unpredictable speed forward structural features: The process consists of three parts, the program, the data and the process Control block. Many different processes can contain the same program: A program that makes different processes in different datasets can get different results, but the program cannot change during execution.

Two. How process status is converted

1. Basic status of the process

(1) Execution status (Running): Process occupies the processor, process is executing the program. Only one process can be in the execution state in a single processor system, and multiple processes in multiprocessor system may be in the execution state.

(2) Wait state (Blocked): Also known as blocking or sleep state, is the state in which the process is paused because it waits for an event to occur. As the process waits for the completion of I/O, waiting for buffer space, etc.

(3) Ready: The process has been assigned to all the necessary resources outside the processor, with all the conditions for execution. Multiple processes may be in a ready state and queued up.

2. Transition of Process state

(1) Ready State-> Execution State: When the process Scheduler allocates a processor to a process that is in a ready state, the process enters the execution state.

(2) Execution Status-> Wait state: The executing process cannot execute because it needs to wait for an event.

(3) Wait state-> Ready state: The event that the process waits for occurs, and the process enters the ready state from the waiting state.

(4) Execution Status-> ready state: The executing process is paused because the time slice is exhausted, or, in a preemptive dispatch mode, when a high priority process arrives, the low priority process being executed is forcibly removed from the processor and converted to a ready state.

Three. How the process is scheduled

Process scheduling algorithm
1.fcfs-first-come-first service algorithm
Algorithm rules: Follow the process into the ready queue sequencing process selection. For process scheduling, once a process consumes the processor, it runs consistently, knowing that the process has completed its work or is unable to continue running because it waits for an event to release the processor.
Features: inalienable, simple to implement
Cons: Not suitable for time-sharing systems. Once a user's process is acquired, the process of other users is not run for a period of time
Not suitable for real-time systems. The inalienable result is that the processor is not available when the higher priority process needs to run.
Obviously, FCFS is the idea or realization of the early multi-channel batch processing system era.

2. Priority scheduling algorithm: Priority-+FCFS
Basic algorithm rules: Implement process scheduling according to the priority of the process, and when multiple processes are at the same priority, select the process based on the principle of first-come-first service (not much like the arithmetic rule).
Features: Suitable for real-time processing, when some process priority is too low to always get the processor, there may be "starvation" phenomenon

Priority scheduling algorithm is also divided into: non-deprivation priority scheduling algorithm and the deprivation of priority scheduling algorithm
non-deprivation priority scheduling algorithm : Once a high-priority process takes over the processor, it runs until the processor is active for its own reasons (execution completes or waits for events) to run another high-priority process
the disenfranchised priority algorithm : Any process scheduling that is appropriate to the principle that the highest priority process runs on the processor. That is, the process that runs on the processing machine always has the highest priority in the ready queue.
As the process runs, once another higher-priority process occurs, it gives the processor a higher-priority process. We call this a preemptive processor (the other side is not willing to rob)

Unix/linux
In the Unix/linux system, the process scheduling algorithm belongs to "The deprivation priority scheduling algorithm", each process priority number is the dynamic priority number, by the system for each process every time calculates once.

3. Time slice rotation scheduling algorithm: Time slice +FCFS
Algorithm rule: Divide the processor time into a number of time slices, in the time slice unit, the process in the ready queue turns (ie first comes first service) uses the processor 1 time slices
Features: Suitable for time-sharing system, deprivation algorithm;

4. Short Process Priority
Algorithm rule: Schedule the program occupancy processor in the ready queue to achieve the shortest average latency based on the elapsed time required by the process
Features: Non-deprivation scheduling, not suitable for real-time system, not line. Run time is difficult to estimate


5. Shortest remaining time (short-term process of deprivation is preferred)
Algorithm rules: Processes that run the process to completion require the shortest running time to be processed first.

Features: Suitable for time-sharing system, to ensure timely response to user requirements; Frequent scheduling of processes with high system overhead
6. Highest response ratio priority scheduling algorithm
Algorithm rules: Scheduling according to the highest response ratio

Response ratio = (wait time + request service time)/Request service time
Features: Non-deprivation scheduling, not suitable for real-time system; High response ratio is preferred.
7. Multilevel Feedback queue scheduling algorithm (time slice + priority +FCFS)
Algorithm considerations:
Take care of the short process in order to improve system throughput and reduce average waiting time;
Take care of I/O process in order to obtain better input utilization rate and to respond to the interaction in time;
In the process running according to the process of the operation of the dynamic nature of the process (mainly calculated or IO-based), and the corresponding scheduling

Algorithm implementation:
Set up multiple process-ready queues, one for each scheduling level. The 1th-level queue has the highest priority, and the subsequent levels of queue priority decreases successively;
Scheduling always selects the highest priority process processor (priority +FCFS);
The time slices that are divided by the processes in the readiness queue are inversely proportional to the priority level. The process with the highest priority has the fewest time slices, and the lower the priority the more time slices (time slices).

Example: first come first service algorithm

Experimental steps

1. Define an array to represent the time each job runs, and then define an array to represent when each job arrives at the system, noting that the time to reach the system is 0 based on the first job (note: If each program reaches the system simultaneously, the system time is 0).

2. Enter the number of jobs.

3. Then, the cyclic structure is used to accumulate the working turnaround time and the weighted turnaround time.

4. Finally, the job turnaround time and the weighted turnaround time are divided by the number of jobs to get the average job turnaround time and the average time to take the right turnaround.

Experiment Code:

#include <iostream>

#include <cmath>

using namespace Std;

int main ()

{

int n,a[100],b[100];

Double s[100],m[100],t=0,w=0;

cout<< "Please enter the number of jobs:" <<endl;

cin>>n;

cout<< "Please enter the time each job arrives at the system:" <<endl;

for (int i=0;i<n;i++)

{

cin>>b[i];

}

cout<< "Please enter the time each job is running:" <<endl;

for (i=0;i<n;i++)

{

cin>>a[i];s[0]=0;

S[i+1]=s[i]+a[i];

M[i+1]= (S[i+1]-b[i])/a[i];

T=t+s[i+1]-b[i];

W=W+M[I+1];

}

cout<< "Average turnaround time is:" <<T/n<<endl;

cout<< "Average take-right turnaround time:" <<W/n<<endl;

return 0;

}

Talk about your view of the operating system process model

The core concept of the operating system is the process, which is also one of the most important and basic concepts in concurrent programming. Process is a dynamic process, that is, the process has a life cycle, it has resources, is the execution process of the program, its state is changing. Windows, UNIX, and Linux are some of the most popular operating systems today. This time because the teacher assigned the homework, so that they will understand, now I do not understand the operating system or clear, so if the summary of the error, but also please a lot of understanding, and help to point out.

First assignment: Deep source Analysis Process Model

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.