什么是基于优先数的调度算法调度算法

优先数调度算法实现处理器调度的代码问题,求大神_操作系统吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:47,952贴子:
优先数调度算法实现处理器调度的代码问题,求大神收藏
这段代码在linux系统下可以正常运行,但是到windows下运行就老是出错,要崩溃了,下午就要检查了啊啊啊啊这是一个按优先数调度算法实现处理器调度的程序。#include&string.h& #include&stdlib.h& #include&stdio.h& #define MAXTIME 5 #define MAXPRIORITY 5 typedef struct Pcb { char name[10];
char state[10]; struct Pcb* }PCB, * link p[5];
void insert( link* q )//insert a process into ready queue at the desired position { link temp = link preTemp = NULL; if( !temp )//remain only one process { ready = (*q);
} while( temp != NULL ) { if( (*q)-&priority & temp-&priority ) { preTemp = temp = temp-& } else
} if( !preTemp ) { (*q)-&next = ready = (*q); } else { preTemp-&next = (*q); (*q)-&next = } } void init() { int i = 0; int a,b;char c = '0';
while( i & 5 ) { p[i] = ( link )malloc( sizeof( PCB ) ); strcpy( p[i]-&name, "P1" ); temp = c + i + 1; p[i]-&name[1] = scanf("%d",&a); p[i]-&time=a%MAXTIME;scanf("%d",&b); p[i]-&priority =b%MAXPRIORITY; strcpy( p[i]-&state, "ready" ); i++; } //insert process into ready queue ready = p[0]; i = 1; while( i & 5 ) { insert( &p[i] ); i++; } } void control() { link temp = ready = ready-& strcpy( temp-&state, "run" ); printf( "\n\n\n当前运行进程为%s\n", temp-&name ); temp-&time--; temp-&priority--;//not restrict to positive number. if( temp-&time == 0 ) { strcpy( temp-&state, "end" ); printf( "进程%s结束\n", temp-&name ); } else//insert into ready queue for next process { strcpy( temp-&state, "ready" ); int i = temp-&name[1] - '0'; insert( &p[i-1] ); } } void print() { printf( "\n--------------进程控制块信息----------\n" ); printf( "进程名\t状态\t剩余时间\t优先数\n" ); int i = 0; while ( i & 5 ) { printf( "%s\t%s\t%d\t\t%d\n\n", p[i]-&name, p[i]-&state, p[i]-&time, p[i]-&priority ); i++; } printf( "-------------------------------------\n" ); printf( "1.继续 0.退出\n" ); scanf( "%d", &i ); if( i == 0 ) exit( 0 ); } int main() { init(); print(); while (ready) { control(); print(); } printf( "所有进程结束\n" ); return 0; }
登录百度帐号推荐应用
为兴趣而生,贴吧更懂你。或> 问题详情
运行时间最短的作业被优先调度,这种企业调度算法是()A.优先级调度B.响应比高者优先C.短作业优先D
悬赏:0&答案豆
提问人:匿名网友
发布时间:
运行时间最短的作业被优先调度,这种企业调度算法是()A.优先级调度B.响应比高者优先C.短作业优先D.先来先服务请帮忙给出正确答案和分析,谢谢!
论文写作技巧
您可能感兴趣的试题
1产生死锁的主要原因是进程运行推进的顺序不合适(&&)A.系统资源不足和系统中的进程太多B.资源的独占性和系统中的进程太多C.进程调度不当和资源的独占性D.资源分配不当和系统资源不足
我有更好的答案
相关考试课程
请先输入下方的验证码查看最佳答案
图形验证:
验证码提交中……优先数调度算法
设计一个有N个进程处于就绪队列时,单处理机情况下的调度程序采取“优先数调度”算法。
进程的就绪队列中是按优先数的大小从大到小排列,调度算法总是选取队列中优先数高的队列投入运行,采取动态地改变优先数的办法,进程每运行一次优先数相应的减2,从而避免一个作业长期占据处理机,当调度时机出现时,调度算法适时再调度,首先判断此进程是否运行完,未运行完再判断此进程的优先权是否大于等于队列的首进程的优先数,若成立,就继续执行。这样重复,直到就绪队列为空。

#include
#include
#include

#define N 5
#define NULL 0
#define LEN sizeof(struct PCB1)

struct PCB1
{




 struct PCB1 *
};

void print10()
{
 printf("*----------------------------------------*\n");
 printf("| PRIORTY ALGORITHM |\n");
 printf("*----------------------------------------*\n");
 printf("\n");
}
void print11()
{
 printf("+----------------------------------------+\n");
}
void print12()
{
 printf("|----------------------------------------|\n");
}
void print13()
{
 printf("| PID |PRIORITY | TIME | STA |\n");
}

void print1(struct PCB1 *head)

{
 struct PCB1 *p;
 p=
 if(head!=NULL)
 {
 print11();
 print13();
 print11();
 do
 {

printf("|�|�|d|�|\n",p-&pid,p-&pri,p-&time,p-&sta);
 print12();
 p=p-&
 }
 while(p!=NULL);
 print11();
 }
}

struct PCB1 *insert(struct PCB1 *head,struct PCB1 *p)

{
 struct PCB1 *p0,*p1,*p2;
 p1=
 p0=p;
 if(head==NULL)
 {
 head=p0;
 p0-&next=NULL;
 }
 else
 {

while((p0-&pri&=p1-&pri)&&(p1-&next!=NULL))
 {
 p2=p1;
 p1=p1-&
 }

if(p0-&pri&p1-&pri)
 {
 if (head==p1)
 head=p0;
 else
 p2-&next=p0;
 p0-&next=p1;
 }
 else
 {
 p1-&next=p0;
 p0-&next=NULL;
 }
 }
 return(head);
}

struct PCB1 *creat1()
{
 struct PCB1 *head,*p;

 head=NULL;
 printf("please input PCB\n");
 printf("format: pri,runtime\n");
 for (i=0;i&N;I++)
 {
 printf("please input p%d PCB\n",i+1);
 p=(struct PCB1 *)malloc(LEN);
 scanf("%d
%d",&p-&pri,&p-&time);
 p-&pid=i+1;
 p-&sta='W';
 head=insert(head,p);
 }
 return (head);
}

struct PCB1 *del(struct PCB1 *head,struct PCB1 *p)

{
 p-&sta='f';
 print1(p);
 printf("processes p%d del \n",p-&pid);
 return(head);
}

void prio(struct PCB1 *head)

{

 struct PCB1 *p,*
 p=
 while(p!=NULL)
 {
 rp=p;
 p=p-&
 do
 {
 flag='y';
 printf("process p%d running\n",rp-&pid);
 rp-&sta='r';
 rp-&pri=rp-&pri-2;
 print1(rp);
 printf("again scheduling\?\n");
 (rp-&time)--;
 rp-&sta='w';
 if (rp-&time==0)
 p=del(p,rp);
 else
 {
 if
((p==NULL)||(rp-&pri&=p-&pri))
 flag='n';
 else
 {
 p=insert(p,rp);
 printf("insert after que\n");
 print1(p);
 }
 }
 }
 while(flag=='n');
 }
}

main()
{
 struct PCB1 *
 head=NULL;
 print10();
 printf("input data\n");
 head=creat1();
 print1(head);
 printf("begin running\n");
 prio(head);
 printf("v");
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。动态优先级调度算法
dynamic-priority
动态优先级调度算法
基于1个网页-
dynamic priority scheduling algorithm
动态优先级调度算法
基于1个网页-
dynamic priority scheduling algorithm
&2,447,543篇论文数据,部分数据来源于
在基于时延的调度算法(BDS)基础上将时间片与优先级相结合,提出了一种基于时延的动态优先级调度算法(DDPQS)。
Investigating queue management based on the delay scheduling(BDS), combining the time chip and priority, advances Delay-based Dynamic Priority Queue Scheduling(DDPQS) algorithm.
第三,基于上述的资源管理体系结构和高性能计算应用模型,提出了一种改进的动态优先级调度算法。
Thirdly, a modified dynamic level scheduling algorithm is presented in accordance with the above resource management architecture and the high performance computing application model.
对基于CAN总线通信的动态优先级调度算法进行研究后,提出了一种基于指数分配方式的MTS算法,在保证强实时性消息的同时兼顾了低优先级消息的公平性。
To study the dynamic priority algorithm on CAN-bus, a mixed traffic scheduler(MTS) based on exponential assignment was proposed. It gives attention to both hard and soft realtime messages.
$firstVoiceSent
- 来自原声例句
请问您想要如何调整此模块?
感谢您的反馈,我们会尽快进行适当修改!
请问您想要如何调整此模块?
感谢您的反馈,我们会尽快进行适当修改!有没有数据结构方面比较厉害的学长,优先数调度算法,求编程
3回复 172浏览
1)假定进程控制块中包含内容为:进程名& &链接指针& &进程的优先数& &估计运行时间& &进程状态& &其中进程名即进程标示符;链接指针是按照进程到达进程就绪队列的时间链接进程的优先数由用户自己指定,并且优先数值越小,优先级越高,调度时,总是选择优先级高的进程占用CPU;估计运行时间可由设计者任意指定一个时间值;(2)根据需要,设计一个队首指针指向5个进程(进程名为A,B,C,D,E)组成的就绪队列中的第一个进程,再设一个当前指针指向当前正在运行的进程。(3)进程调度时,采用静态优先调度。(4)用非抢占式方式分配处理器。(5)要求所设计的程序必须有输出语句,用于输出进程调度和运行一次后进程的变化。比如:每次被选中的进程名,就绪队列中进程的排队情况,进程控制块的动态变化。
在寝室的厕所撒尿时,窗开着,我端着我的JB,看着楼下走过的一个个MM,突然感觉无比寂寞……
怎么都没人理我,,,,
在寝室的厕所撒尿时,窗开着,我端着我的JB,看着楼下走过的一个个MM,突然感觉无比寂寞……
数据结构考研才考过,不过短短2月忘完了发自手机虎扑
引用2楼 @ 发表的:
数据结构考研才考过,不过短短2月忘完了
考研也有这门课啊,好难的。。。
在寝室的厕所撒尿时,窗开着,我端着我的JB,看着楼下走过的一个个MM,突然感觉无比寂寞……
您需要登录后才可以回复,请
& 允许多选

我要回帖

更多关于 动态优先级调度算法 的文章

 

随机推荐