current position:Home>Short process first scheduling algorithm
Short process first scheduling algorithm
2022-01-26 22:02:30 【Exposed wet dust】
example < Two > Programming short process first scheduling algorithm The specific implementation procedure is as follows : #include<stdio.h> #define n 5 #define num 5 #define max 65535 typedef struct pro { int PRO_ID; int arrive_time; int sum_time; int flag; }Pro;//l Integer sort int bubble(int temp[]) { int i,j,tem=0; for(i=1;i<num;i++) { int lastX=1; for(j=0;j<num-i;j++) { if(temp[j]>temp[j+1]) {tem=temp[j]; temp[j]=temp[j+1]; temp[j+1]=tem; lastX=0; } } if(lastX==1) break; } return temp[0]; } // Process sequencing Pro bubble(Pro p[]) { int i,j; Pro temp={0}; Pro s[num]; for(i=0;i<num;i++) {s[i]=p[i]; } for(i=1;i<num;i++) { int lastX=1; for(j=0;j<num-i;j++) { if(s[j].sum_time>s[j+1].sum_time) { temp=s[j]; s[j]=s[j+1]; s[j+1]=temp; lastX=0; } } if(lastX==1)break; } return s[0]; } void SPF(int p) { if(n>0) { int i,j,k,l,tc=0; Pro seq[n]; Pro temp_seq[n]; printf(" Short process priority scheduling algorithm SPFln"); printf(" Please input... In turn 5 The process number of a process 、 Arrival time and execution time n");printf(" Member variables are separated by commas ﹔ The processes are separated by carriage return \n"); for(i=0;i<n;i++){ scanf("%d,%d,%d",&seq[i].PRO_ID,&seq[i].arrive_time,&seq[i].sum_time); } printf(" The scheduling order is :\n");// initialization tc int temp[num]; for(i=0;i<num;i++) { temp[i]=seq[i].arrive_time; } tc=bubble(temp);//tc It's a breakpoint //flag Indicates correspondence i Of pro The queue situation //-1 Indicates that you have not entered the queue ,0 Indicates that in the queue ,1 Indicates that it has been cleared for(i=0;i<n;i++){ seq[i].flag=-1; } for(i=0;i<n;i++){ for(j=0;j<n;j++){ if(seq[i].flag!=1&&seq[i].arrive_time<=tc){ seq[j].flag=0; } } for(j=0;j<n;j++){ temp_seq[j]=seq[j]; if(seq[j].flag!=0){ temp_seq[j].sum_time=max; } } l=bubble(temp_seq).PRO_ID; for(j=0;j<n;j++){ if(l==seq[j].PRO_ID){ k=j; } } tc=tc+bubble(temp_seq).sum_time; seq[k].flag=1; printf("%d",l); } printf("\n"); } } void main() { SPF(n); } No error in execution : Input 5 A process to test the program , The program results are as follows : |
Four 、 Summary of the experiment |
In this experiment, I learned Visual C++ 6.0 To realize the short process first service strategy in the process scheduling strategy of operating system course , In this experiment, I know that the advantage of this strategy is that it improves the average performance compared with the first come first serve strategy Turnaround time And the average Turnaround time with rights , Reduce job waiting time ; Improve system throughput ; In the final experimental results, the process 5 Has not been implemented , I can conclude that the disadvantage of this algorithm is that it is very disadvantageous to long jobs , May not be implemented for a long time ; And the priority of execution is not divided according to the urgency of the job ; It is difficult to estimate the work accurately ( process ) Execution time of , This will affect the scheduling performance . |
copyright notice
author[Exposed wet dust],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201262202275381.html
The sidebar is recommended
- Spring IOC container loading process
- [thinking] the difference between singleton mode and static method - object-oriented programming
- Hadoop environment setup (MySQL environment configuration)
- 10 minutes, using node JS creates a real-time early warning system for bad weather!
- Git tool
- Force deduction algorithm - 92 Reverse linked list II
- What is the sub problem of dynamic programming?
- C / C + +: static keyword summary
- Idea does not have the artifacts option when configuring Tomcat
- Anaconda can't open it
guess what you like
-
I don't know how to start this
-
Matlab simulation of transportation optimization algorithm based on PSO
-
MySQL slow log optimization
-
[Vue] as the window is stretched (larger, smaller, wider and higher), the text will not be displayed
-
Popular Linux distributions for embedded computing
-
Suzhou computer research
-
After installing SSL Certificate in Windows + tomcat, the domain name request is not successful. Please answer!!
-
Implementation time output and greetings of jQuery instance
-
The 72 year old uncle became popular. Wu Jing and Guo fan made his story into a film, which made countless dreamers blush
-
How to save computer research
Random recommended
- Springboot implements excel import and export, which is easy to use, and poi can be thrown away
- The final examination subjects of a class are mathematical programming, and the scores are sorted and output from high to low
- Two pronged approach, Tsinghua Professor Pro code JDK and hotspot source code notes, one-time learning to understand
- C + + recursive knapsack problem
- The use of GIT and GitHub and the latest git tutorial are easy to understand -- Video notes of crazy God speaking
- PostgreSQL statement query
- Ignition database test
- Context didn't understand why he got a high salary?, Nginxfair principle
- Bootstrap switch switch control user's guide, springcloud actual combat video
- A list that contains only strings. What other search methods can be used except sequential search
- [matlab path planning] multi ant colony algorithm grid map path planning [including GUI source code 650]
- [matlab path planning] improved genetic algorithm grid map path planning [including source code phase 525]
- Iinternet network path management system
- Appium settings app is not running after 5000ms
- Reactnative foundation - 07 (background image, status bar, statusbar)
- Reactnative foundation - 04 (custom rpx)
- If you want an embedded database (H2, hsql or Derby), please put it on the classpath
- When using stm32g070 Hal library, if you want to write to flash, you must perform an erase. If you don't let it, you can't write continuously.
- Linux checks where the software is installed and what files are installed
- SQL statement fuzzy query and time interval filtering
- 69. Sqrt (x) (c + + problem solving version with vs runnable source program)
- Fresh students are about to graduate. Do you choose Java development or big data?
- Java project: OA management system (java + SSM + bootstrap + MySQL + JSP)
- Titanic passenger survival prediction
- Vectorization of deep learning formula
- Configuration and use of private image warehouse of microservice architect docker
- Relearn JavaScript events
- For someone, delete return 1 and return 0
- How does Java dynamically obtain what type of data is passed? It is used to judge whether the data is the same, dynamic data type
- How does the database cow optimize SQL?
- [data structure] chain structure of binary tree (pre order traversal) (middle order traversal) (post order traversal) (sequence traversal)
- Webpack packaging optimization solution
- 5. Operation element
- Detailed explanation of red and black trees
- redhat7. 9 install database 19C
- Blue Bridge Cup notes: (the given elements are not repeated) complete arrangement (arrangement cannot be repeated, arrangement can be repeated)
- Detailed explanation of springboot default package scanning mechanism and @ componentscan specified scanning path
- How to solve the run-time exception of test times
- Detailed explanation of k8s management tool kubectl
- Android system view memory command