我有这些结构:
typedef struct _Frag{
struct _Frag *next;
char *seq;
int x1;
int length;
}Frag;
typedef struct _Fragment{
int type;
Frag *frag_list;
}Fragment;
然后我创建了一个数组
Fragment *fragments=malloc(1,sizeof(Fragment)); // or more
fragments->frag_list=malloc(1,sizeof(Frag)); // or mor
这里是我的问题:我想从运行在Linux内核空间中的代码中对数据文件的一部分进行内存映射。我想稍后也从Linux内核空间中运行的代码中撤销相同的内存映射。如何执行这些操作?它们与在用户空间中使用mmap(2)/munmap(2)有何不同?
我试图在没有用户进程的内核空间中做到这一点。
我浏览了网络搜索和Linux内核书籍,包括Bovet和Cesati的"Understanding the Linux Kernel“。一本好书,但没有回答我的问题。
我的测试源码是:
volatile int gl = 0;
void * InternalHandler( void * param )
{
for ( int i = 0; i < 100000; ++i ) { ++gl; }
return 0;
}
int main()
{
pthread_t ths[100] = { 0 };
for ( int i = 0; i < 100; ++i)
{
pthread_create( &ths[ i ], 0, InternalHandler, 0 );
}
for ( int i =
下面是一小块汇编代码(我使用的语法)。
.extern cos
.section .data
pi: .double 3.14
.section .text
.global slowcos
.global fastcos
fastcos:
fldl pi
subl $8, %esp # makes some space for a double on the stack
fstpl 0(%esp) # copy pi on top of the stack
call cos
addl $8, %esp
ret
slowcos:
push