| 
 | 
我修改了sched.h中的 
struct sched_param { 
        int sched_priority; 
        unsigned long long  period;                               
        unsigned long long  servicetime;                      
};下面2个成员是我自己加的,现在内核在开发板上能最缺运行 
应用程序如下: 
#include <stdio.h> 
#include <unistd.h> 
#include <stdlib.h> 
#include <pthread.h> 
#include <sys/resource.h> 
#include </opt/EmbedSky/linux-2.6.30.4/include/linux/sched.h> 
//#include <sched.h> 
 
#define N 3 
FILE *fp = NULL; 
 
void *(*pf[N])(void); 
 
void *process_0(void)  
{ 
        struct sched_param param; 
        char start[] = "FIFO  task 0 start\n"; 
        char end[] = "FIFO  task 0 end\n"; 
        int count = 0,p=3; 
        while(p--) 
        { 
                fputs(start,fp); 
                /*do 
                { 
                        count++; 
                }while(count<1000000);*/ 
                sleep(2); 
                fputs(end,fp); 
        } 
        //sleep(5); 
        sched_getparam(0,¶m); 
        printf("policy:%d,priority:%d\n",sched_getscheduler(getpid()),param.sched_priority); 
        printf("0 func\n"); 
} 
 
void *process_1(void)  
{ 
        struct sched_param param; 
        char start[] = "task 1 start\n"; 
        char end[] = "task 1 end\n"; 
        struct timeval tstart,tend; 
        int count = 0,p=3; 
        while(p--) 
        { 
                fputs(start,fp); 
                do 
                { 
                        count++; 
                }while(count<1000000); 
                fputs(end,fp); 
        } 
        sched_getparam(0,¶m); 
        printf("璋冨害绛栫暐:%d,浼樺厛绾?%d\n",sched_getscheduler(getpid()),param.sched_priority); 
        printf("1 func\n"); 
} 
 
void *process_2(void)  
{ 
        struct sched_param param; 
        char start[] = "task 2 start\n"; 
        char end[] = "task 2 end\n"; 
        struct timeval tstart,tend; 
        int count = 0,p=3; 
        while(p--) 
        { 
                fputs(start,fp); 
                do 
                { 
                        count++; 
                }while(count<1000000); 
                fputs(end,fp); 
        } 
        sched_getparam(0,¶m); 
        printf("璋冨害绛栫暐:%d,浼樺厛绾?%d\n",sched_getscheduler(getpid()),param.sched_priority); 
        printf("2 func\n"); 
} 
 
void Process_Init() 
{ 
        int i; 
        //for(ik=0;i<N;i++) 
        pf[0] =  process_0; 
        pf[1] =  process_1; 
        pf[2] =  process_2; 
} 
 
int main() 
{ 
        int res,i; 
        pid_t pid,ptask[N]; 
 
 
        struct sched_param param; 
        if((fp = fopen("fifo.txt","a+")) == NULL) 
        {                 
                printf("can't open fifo.txt"); 
                return -1; 
        } 
         
        Process_Init(); 
         
        //for(i=0;i<3;i++) 
        //{ 
                if((pid=fork()) == -1) 
                { 
                        perror("fork"); 
                        exit(EXIT_FAILURE); 
                } 
                else if(pid == 0) 
                { 
                         
                        param.sched_priority=10; 
                        //param.period=20000;                      
                        //param.servicetime=10000; 
                         
                        sched_setscheduler(getpid(),SCHED_LLF,¶m); 
                        printf("param set end\n"); 
                        pf[0](); 
                        //printf("%d\n",i); 
                        exit(0); 
                } 
        //} 
        fclose(fp); 
        return 0; 
} 
 
主要问题在param的2个成员不能识别,请问这种问题应该怎么编译呢? |   
 
 
 
 |