资源简介

模拟实现操作系统进程管理

资源截图

代码片段和文件信息

#include 
#include 
#include“.\include\queue.h“
#include“string.h“
int main()
{
    consolePrint();
    int initNum;
    scanf(“%d“&initNum);
    if(initNum==1) init();
    else if(initNum==2) {init2();
    DisplayQueue();}
    else init();
    char input[100];
    int inNumeber;
    while(1)
    {
        printf(“Please input the operating number you want to:\n“);
        scanf(“%d“&inNumeber);
        if(inNumeber==0) break;
        else if(inNumeber==1)
        {
            printf(“please input the process name and priority following the method mentioned above:\n“);
            scanf(“%s“input);
            char *tokenPtr=strtok(input“:“);
            char* res[10];
            int arrayIndex=0;
            while(tokenPtr!=NULL)
            {
                res[arrayIndex] = tokenPtr;
                tokenPtr=strtok(NULL“:“);
                arrayIndex ++;
            }
            char* name = (char*)malloc(sizeof(char)*16);
            int priority=3;
            if(arrayIndex==1) strcpy(nameres[0]);
            else if(arrayIndex=2)
            {
                strcpy(nameres[0]);
                priority =atoi(res[1]);
            }
            else {printf(“Wrong Instruction format!\n“);continue;}
            struct process newProcess = {autoPID++nameREADYpriority10};
            struct QueueNode* newNode = (struct QueueNode*)malloc(sizeof(struct QueueNode));
            newNode->task = newProcess;
            newNode->next = NULL;
            createProcess(newNode);
            DisplayQueue();
        }
        else if(inNumeber==2)
        {
            //printf(“this function don‘t need you to input\n“);
            blockProcess();
            DisplayQueue();
        }
        else if(inNumeber==3)
        {
            printf(“please input the process name and priority following the method mentioned above:\n“);
            scanf(“%s“input);

            char *tokenPtr=strtok(input“:“);
            char* res[10];
            int arrayIndex=0;
            while(tokenPtr!=NULL)
            {
                res[arrayIndex] = tokenPtr;
                tokenPtr=strtok(NULL“:“);
                arrayIndex ++;
            }
            int PID;
            if(arrayIndex==1||arrayIndex==2||arrayIndex==3)
                PID = atoi(res[0]);
            else {printf(“Wrong Instruction format!\n“);continue;}
            //DisplayQueue();
            struct process newProcess = {PID};
            struct QueueNode* newNode = (struct QueueNode*)malloc(sizeof(struct QueueNode));
            newNode->task = newProcess;
            newNode->next = NULL;
            //DisplayQueue();/**< for debug */
            wakupProcess(newNode);
            DisplayQueue();
        }
        else if(inNumeber==4)
        {
             printf(“please input the process name and priority following the method mentioned above:\n“);
            scanf

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-05-24 19:15  process\
     目录           0  2018-05-17 21:28  process\bin\
     目录           0  2018-05-18 21:43  process\bin\Debug\
     文件       82866  2018-05-18 21:43  process\bin\Debug\process.exe
     目录           0  2018-05-18 13:04  process\include\
     文件          93  2018-05-18 10:11  process\include\global.h
     文件         340  2018-05-18 09:58  process\include\process.h
     文件        1228  2018-05-18 13:04  process\include\queue.h
     文件        3893  2018-05-18 15:10  process\main.c
     目录           0  2018-05-17 21:28  process\obj\
     目录           0  2018-05-18 21:43  process\obj\Debug\
     文件        6782  2018-05-18 21:43  process\obj\Debug\main.o
     目录           0  2018-05-18 14:35  process\obj\Debug\src\
     文件         509  2018-05-18 10:11  process\obj\Debug\src\global.o
     文件       11285  2018-05-18 14:35  process\obj\Debug\src\queue.o
     文件        1261  2018-05-18 15:02  process\process.cbp
     文件         598  2018-05-24 19:01  process\process.depend
     文件         925  2018-05-24 19:15  process\process.layout
     目录           0  2018-05-18 14:35  process\src\
     文件          51  2018-05-18 10:11  process\src\global.c
     文件        8722  2018-05-18 14:35  process\src\queue.c

评论

共有 条评论