============高手快来,救小的一下下!!==============================

Aegis 2002-11-27 10:14:16
小的在写一个内核模块,其中因为有多进程,所以引入了信号量。程序在编译时没有任何问题,但在insmod时提示unresolved symbol sys_semctl。

下面是我测试时抠出来的一段代码(以便排除问题出在其他部分的可能性):

/* gcc -c -Wall test.c*/


#define __KERNEL__
#define MODULE

#include <linux/module.h>
#include <linux/kernel.h>

#include <linux/string.h>
#include <linux/types.h>
#include <linux/ipc.h>
#include <linux/sem.h>
#include <linux/slab.h> /*kmalloc(), kfree()*/
#include <linux/stat.h>

#include <asm/types.h>
#include <asm/ipc.h>
#include <asm/uaccess.h>
#include <asm/semaphore.h>

key_t ftok(path, id)
const char *path;
char id;
{
struct stat st;

/* if (stat(path, &st) < 0)
return (key_t)-1;*/

return (key_t) (id << 24 | (st.st_dev & 0xff) << 16 | (st.st_ino & 0xfff
));
}

init_module()
{
int i;
int AgentLock;
union semun options;
key_t MyKey = ftok( ".", "xyz" );
AgentLock = sys_semget( MyKey, 5, IPC_CREAT | IPC_EXCL );

options.val = 1;
for( i = 0; i < 5; i++ )
sys_semctl( AgentLock, i, SETVAL, options );
}


哪位高人帮我看看?小的实在不知道该咋办了!!
...全文
41 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwwunix 2002-11-28
  • 打赏
  • 举报
回复
你将kernel重新编译试试
wmrwinhap 2002-11-28
  • 打赏
  • 举报
回复
gz

23,218

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧