linux下进程调度模拟程序,linux认证辅导:linux进程调度模拟怎么做?
/*模擬實現LINUX進程調度的靜態優先級算法和時間片輪轉算法引入LINUX調度 */ #include #include #include
#include #include #define RUN 1 #define SLEEP 0 #define READY 2 #define DEG_SCHEDULE #define NUM 6 struct OSPCB { int PcbName ; /*進程名字*/ int ReqCount; /*進程執行計數*/ int RunTime; /*進程執行時間數*/ int Prority; /*進程優先級*/ int PcbStatus; /*進程狀態*/ int PcbTime; /*進程時間片*/ struct OSPCB* prev; struct OSPCB *next; }; struct ProcessQueue /*模擬CPU調度隊列*/ { struct OSPCB *PointerHead; /*指向進程鏈表頭*/ int PcbNumber; /*CPU每次調度計數器*/ }; //static struct CriticalResource //{ // int flag; // char BufferVoice[2000]; //} static int flag; void *Function(int *arg); void InitPcb(struct OSPCB *pcb); int Schedule(struct ProcessQueue *queue); void InheritSchedule(struct OSPCB *pcb); int main(void) { int i,ret; struct OSPCB *pNewPcb,*pNew; struct ProcessQueue *pNewQueue; int a[4][4] = {{1,1,0,1},{2,2,0,2},{3,3,0,3},{4,4,0,4}}; pNewQueue = (struct ProcessQueue *)malloc(sizeof(struct ProcessQueue)); pNewQueue->PointerHead = NULL; pNewQueue->PcbNumber = 0; for(i = 0; i PcbName = a[i][0]; pNewPcb->ReqCount = a[i][1]; pNewPcb->RunTime = a[i][2]; pNewPcb->Prority = a[i][3]; pNewPcb->PcbStatus = READY; pNewPcb->PcbTime = 3; InitPcb(pNewPcb);
。
全部
總結
以上是生活随笔為你收集整理的linux下进程调度模拟程序,linux认证辅导:linux进程调度模拟怎么做?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 英雄联盟祖安服务器要维护多久,祖安玩家的
- 下一篇: python实现冒泡排序算法的非递归版本