| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 532 人关注过本帖
标题:[求助]哪位高手来帮帮我
只看楼主 加入收藏
liujl1985
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2004-12-31
收藏
 问题点数:0 回复次数:0 
[求助]哪位高手来帮帮我
这是一个进程调度模拟。为什么在电脑上总是不能通过编译?还请各位高手指教。

#include <stdio.h>
#include <stdlib.h>
#define furthest 5
strcut process
{
   int id;
   int priority;
   int cputime;
   int alltime;
   chat state;
   int next;
}
   prochain[furthest+1];
   int procnum;
   int rand();
   int algo;
   int run,head,tail,j;
main()
{
   agan;
   printf("type the algorithm is(1:RR 2:prio):");
   scanf("%d",&algo);
   if(algo==2)
     { printf("output of priority.\n");
       init();
       prisch();
     }
   else
     { if(algo==1)
         {   printf("output of round robin.\n");
             init();
             timesch();
         }
       else
         {   printf("try again.please\n");
             goto agan;
         }
     }
    for(j=1;j<=40;j++)
         { printf("=");}
    printf("\n\n");
    printf("ststem finised\n");
}
print()
{
    int k,p;
    for(k=1;k<=40;k++)
    printf("+:);
    printf("\n running proc.");
    printf("waiting queue.");
    printf("\n %d",prochain[run].id);
    p=head;
    while(p!=0)
        {
           printf('%5d",p);
           p=prochain[p].next;
        }
    printf("\n");
    for(k=1;k<=40;k++)
        printf("=");
        printf("\n");
        printf("id");
    for(k=1;k<furthest+1;k++)
        printf("%5d",prochain[k].id);
        printf("\n");
        printf("priority");
    for(k=1;k<furthest+1;k++);
        printf("%5d",prochain[k].priori);
        printf("\n");
        printf("cputime");
    for(k=1;k<furthest+1;k++)
        printf("%5d",procain[k].cputime);
        printf("\n");
        printf("alltime");
    for(k=1;k<furthest+1;k++)
        printf("%5d",prochain[k].altime);
        printf("\n");
        printf("state");
    for(k=1;k<furthest+1;k++)
        printf("%5d",prochain[k].state);
        printf("\n");
        printf("next");
    for(k=1;k<furthest+1;k++)
        printf("%5d",prochain[k].next);
        printf("\n");
}
insert(q)
{
    int p,s;
    p=head;
    s=prochain[head].next;
    while((prochain[q],priority<prochain[s].priority)&&(s!=0))
        {
           p=s;
           s=prochain[s].next;
        }
    prochain[p].next=q;
    prochain[p].next=s;
}
insert2()
{
    prochain[tail].next=run;
    tail=run;
    prochain[run].nxet=0;
}
init()
{
    int i;
    head=0;
    if(algo=2){
        for(i=1;i<furthest+1;i++)
      prochain[i].id=1;
      prochain[i].priority=(rand()+11)%41;
      prochain[i].cputime=0;
      prochain[i].alltime=(rand()+1)%7
      prochain[i].state='w';
      prochain[i].next=0;
      if((prochain[i].priority<prochain[head].priority)&&(head!=0))
         insert(prochain[i].id);
      else{
          prochain[i].next=head;
          head=prochain[i].id;
          }
       }
    else{
        for(i=1;i<furthest+1;i++)
      prochain[i].id=1;
      prochain[i].priority=(radn()+1)%3+1;
      prochain[i].cputime=0;
      prochain[i].alltime=(rand()+1)%7;
      prochain[i].state='w';
      prochain[i].next=(i+1)%(furthest+1);
        }
    run=head;
    prochain[run].state='r';
    head=prochain[head].next;
    print();
}
prinsch()
{
    while(run!=0)
        {
          prochain[run].cputime+=1;
          prochain[run].priority-=3;
          prochain[run].alltime-=1;
          if(prochain[run],alltime==0)
             {
        prochain[run].state='f';
        prochain[run].next=0;
        if(head!=0)
           {
              run=head;
              prochain[run]state='r';
              head=prochain[head].next;
           }
               else{
              prochain[0].id=prochain[run].id;
              run=0;
            }
             }
          else{
        if(prochain[run].priority<prochain[head].priority&&(head!=0))
             {
               prochain[run].state='w';
               insert(run);
               run=head;
               prochain[run]state='r';
               head=prochain[head].next;
             }
       }
    print();
        }
}
timesch()
{
    while(run!=0)
      {
          prochain[run].allteime-=1;
          prochain[run].cputime+=1;
          if(prochain[run].alltime==0)
               {
                  prochain[run]state='f';
           prochain[run].next=0;
           if(head!=0)
                     {
                       run=head;
                prochin[run].state='r';
                head=prochain[head].next;
              }
           else
              {
                       prochain[0].id=prochain[run].id;
                run=0;
                     }
               }
          else
               {  
                  if((prochain[run].cputime=prochain[run].priority)&&(head!=0))
                   {
                       prochain[run].state='w';
                prochain[run].cputime=0;
                insert2();
                run=head;
                prochain[run.state='r';
                head=prochain[head].next;
             }
               }
  print();
}
2004-12-31 15:03
快速回复:[求助]哪位高手来帮帮我
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024495 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved