天嵌 ARM开发社区

 找回密码
 注册
查看: 2607|回复: 8

修改内核后,怎么编译程序呢?

[复制链接]
xiangbing1987 发表于 2012-2-14 09:41:02 | 显示全部楼层 |阅读模式
我对Linux2.6.40.4的include/linux/sched.h中的一个结构体添加过2个成员,重新编译内核,在开发板上正确运行。
现在我在虚拟机中编写应用程序,要对这个sched.h中的结构体操作,
#arm-linux-gcc -L /opt/EmbedSky/linux2.6.30.4/include/linux  -o llf     llf.c
出错,提示那2个成员找不到,不能识别!!!
请问我应该怎么做,才能编译成对应的应用程序呢?谢谢!
 楼主| xiangbing1987 发表于 2012-2-14 10:00:21 | 显示全部楼层
在线等!!!!
TQ-lkp 发表于 2012-2-14 17:35:45 | 显示全部楼层
贴代码上来看看
 楼主| xiangbing1987 发表于 2012-2-14 20:00:47 | 显示全部楼层
我修改了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,&param);
        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,&param);
        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,&param);
        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,&param);
                        printf("param set end\n");
                        pf[0]();
                        //printf("%d\n",i);
                        exit(0);
                }
        //}
        fclose(fp);
        return 0;
}

主要问题在param的2个成员不能识别,请问这种问题应该怎么编译呢?
 楼主| xiangbing1987 发表于 2012-2-14 20:04:29 | 显示全部楼层
我的QQ:
344831602
vcfwinkey 发表于 2012-2-14 20:32:41 | 显示全部楼层
xiangbing1987 发表于 2012-2-14 20:00
我修改了sched.h中的
struct sched_param {
        int sched_priority;

估计是#include </opt/EmbedSky/linux-2.6.30.4/include/linux/sched.h>这一句错误了,你试下#include <linux/sched.h>
 楼主| xiangbing1987 发表于 2012-2-14 21:11:34 | 显示全部楼层
不是这样的,我本来就是要用到修改后的结构体,因此就不用原来的了,
这该怎么编译呢?
qianguozheng 发表于 2012-2-15 20:37:52 | 显示全部楼层
这是内核头文件,不是普通函数头文件,只有驱动程序可以调用吧
亚瑟王 发表于 2012-2-27 14:04:44 | 显示全部楼层
亲,你到编译器所在的目录下,找到这个头文件,然后做相应的改动后就可以解决了。\opt\EmbedSky\4.3.3\arm-none-linux-gnueabi\libc\usr\include\linux/sched.h
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号-2 )

GMT+8, 2024-9-29 05:29 , Processed in 1.020547 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表