北大操作系统(本)上机考试题总结(完整版) 布丁整理
一、 进程调度
进程调度算法有 FIFO,优先数调度算法,时间片轮转调度算法,分级调度算法,目前主要是考 FIFO
和优先数调度算法(静态优先级)。
进程调度算法的数据结构主要有:进程
函数定义:建立进程函数,进程调度函数
一个网友做的一个 FIFO 调度算法的示例:
#include "stdio.h"
#define max 100
#define pfree 0 /*process end*/
#define running 1 /*process running status*/
#define aready 2 /*process aready status */
#define blocking 3 /*process aready blocking status*/
typedef struct node
{
char name;
int status;
int precendence;
int ax,bx,cx,dx;
int pc;
int psw;
struct node *next; /*pcb define*/
}pcb;
pcb *createprocess(pcb *head)
{
pcb *p,*q;
int a,b,c,d,m,n;
char ID;
int s;
q=NULL;
printf("input the first seven status pcb:");
scanf("%c",&ID);
scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&m,&n);
while(ID!='*')
{
p=(pcb*)malloc(sizeof(pcb));
p->name=ID;
p->ax=a;
1