⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shared.h

📁 A small program to simulate priority scheduling in Unix.
💻 H
字号:
#define _XOPEN_SOURCE#include <stdio.h>#include <sys/types.h>#include <unistd.h>#include <stdlib.h>#include <sys/wait.h>#include <sys/timeb.h>#ifdef linux#include <getopt.h>#endif#include <string.h>#define TRUE -1#define FALSE 0#define OK    0#define NotOK -1#define MAX_PROCS  10#define OPEN_FAILED 1#define MALLOC_FAILED 2#define QUANTUM 100#define NO_DATA 3typedef struct BURST {	int             quantum;	int             ready_wait;	int             io_wait;	struct BURST   *f_link;	struct BURST   *b_link;}               burstStruct;typedef struct PCB {		/* pseudo process tale entry       */	struct PCB     *f_link;	/* forward link for linked list    */	struct PCB     *b_link;	/* backward link for linked list above links				 * allow double-linked */	int             time_required;	/* this is bogus -- real processes do					 * not know in advance how long they					 * will run */	int             time_used;	/* How long has it has run         */	int             initial_priority;	/* used in some sceduling						 * schemes  */	int             current_priority;	/* used with boost/reduce						 * systems  */	int             start_clock;	/* to determine clock time         */	int             end_clock;	/* to determine clock time         */	int             boost_time;	/* time process was last boosted   */	int             CPU_time;	/* time from last CPU access       */	int             job_class;	/* bogus category values are:					 *					 * 0 = interactive (all short CPU					 * bursts)					 *					 * 1 = mixed (some short CPU bursts some					 * long ones)					 *					 * 2 = CPU intensive (usually uses full					 * quantum  */	burstStruct    *BurstHead;	 /* linked list of CPU bursts       */	burstStruct    *BurstTail;	 /* to allow output in order        */	int             used_full;	 /* TRUE if full quantum used       */	int             pid;	         /* process ID for this process     */	int             to_ready;        /* time the process is passed to the					                          * ready queue */	int             io_wait;         /* sum of IO wait time for process */	int             io_complete;     /* time when process will come off					                          * IO wait queue */	int             ready_wait;      /* sum of time process is on ready queue */	int             proc_no;         /* ID number from the data file    */}PCB_entry;/* * the following functions need to be implemented by the student It is * important that the interface remain exactly as it is or the linkages to * sched.o will not work */PCB_entry      *schedule_next(void);	/* function to return next process					 * for the "CPU" */int             insert_new(PCB_entry *);	/* called to insert process						 * into run queue */int             re_insert(PCB_entry *, int);	/* called after a process						 * finishes on the CPU */void            list_q(void);	/* this is a debugging function  */int             init_q(void);	/* initialise the ready queue    *//* this is the end of the functions that students will need to write */int             Clock(int);	/* simulated clock -- maintains count  */int             report_quantum(void); /* a function that reports the																			 * current CPU quantum */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -