我正在添加Linux系统调用,并且不断收到页面错误/细分错误,但我不知道为什么。以下是相关代码:
typedef struct _control_entry
{
struct list_head list;
int time;
} control_entry;
void control_update(control_entry* head)
{
control_entry* pos;
printk("ENTERING update LOOP");
list_for_each_entry(pos, &head->list, list)
{
printk("ENTERED UPDATE LOOP. IS: %d", pos->time);
pos->time -= 1;
printk("FINSIHED PRIMARY DECREMENTATION. IS: %d", pos->time);
if (pos->time <= 0)
{
printk("REMOVING");
list_del(&pos->list);
/*
printk("REMOVING ENTRY");
pos->list.prev->next = pos->list.next;
printk("FIRST STAGE DONE");
pos->list.next->prev = pos->list.prev;
printk("FINISHED REMOVING ENTRY");
*/
}
}
}
asmlinkage long sys_control(void)
{
//an array of 100 randomly generatred numbers in the range of 1-1000. Used as the different times each thread will sleep for in this experiment
//numbers were generated from https://www.random.org/integer-sets/, an online web service that bases its random numbers off of atmosphereic noise
int sleep_times[] = {532, 58, 542, 573, 924, 379, 753, 183, 268, 254, 803, 188, 794, 936, 976, 585, 755, 189, 905, 880, 911, 396, 889, 348, 629, 515, 830, 107, 452, 47, 857, 650, 14, 524, 548, 476, 551, 953, 366, 572, 419, 450, 134, 748, 944, 904, 557, 651, 788, 92, 982, 901, 11, 5, 72, 798, 447, 658, 843, 445, 204, 380, 392, 385, 199, 426, 474, 139, 404, 274, 511, 74, 540, 244, 827, 330, 342, 598, 487, 206, 606, 261, 81, 772, 603, 323, 920, 430, 67, 316, 706, 801, 716, 307, 703, 657, 228, 712, 434, 898};
int i;
control_entry chead = {LIST_HEAD_INIT(chead.list), NULL};
control_entry entry[100];
for (i = 0; i < 100; i++)
{
INIT_LIST_HEAD(&entry[i].list);
entry[i].time = sleep_times[i];
list_add(&entry[i].list, &chead.list);
}
printk("ENTERING MAIN CONTROL");
do
{
printk("RUNNING MAIN CONTROL");
control_update(&chead);
printk("RAN MAIN CONTROL");
msleep(1);
}
while(dq_sizea(&chead.list) > 0);
return 0;
}
我对C和Linux还是比较陌生,所以如果这是一个明显的错误,我就打个招呼。我似乎无法理解我在做什么错。