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

📄 psched.c~

📁 设有二元函数 f(x,y) = f(x) + f(y) 其中:f(x) = f(x-1) * x (x>1) f(x) = 1 (x=
💻 C~
字号:
/*      *      Filename           : psched.c      * copyright         : (C) 2006 by zhanghonglie                                : 父进程创建 3 个子进程为它们设置不同的优先数和调      *      Function度策略*/#include <stdio.h>#include <stdlib.h>#include <sched.h>#include <sys/time.h>#include <sys/resource.h>int main(int argc, char *argv[]){   int i,j,status;   int pid[3];    struct sched_param p[3];for(i=0; i<3;i++){if((pid[i]=fork()) >0){     p[i].sched_priority = (argv[i+1] != NULL) ? atoi(argv[i+1]):10;     sched_setscheduler(pid[i],(argv[i+4] != NULL) ? atoi(argv[i+4]) :SCHED_OTHER,&p[i]);     setpriority(PRIO_PROCESS,pid[i],(argv[i+1] != NULL) ? atoi(argv[i+1]):10);}else{ sleep(1); for(i=0; i<10; i++){ printf("Child PID = %d priority =%d\n",getpid(),getpriority(PRIO_PROCESS,0));          sleep(1);       }         exit( EXIT_SUCCESS);     }   }  printf("My child %d policy is %d\n",pid[0],sched_getscheduler(pid[0]));  printf("My child %d policy is %d\n",pid[1],sched_getscheduler(pid[1]));  printf("My child %d policy is %d\n",pid[2],sched_getscheduler(pid[2]));  return EXIT_SUCCESS;}

⌨️ 快捷键说明

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