hi there i’m trying to compile my new kernel from kernel version 2.4.20. Moreover, i have a header file which includes the definitions of structures (one for to define node used by a linked list and a list structure) and two function prototypes which are defined in my new systemcall file sample.c . However, when i define a list globally and try to make an allocation in sched.c in function sched_init() my new kernel version doesnt open. it stucks before get started. here you can see my header file and system call file.
/* project_header.h */
#ifndef __LINUX_PROJECT_HEADER_H
#define __LINUX_PROJECT_HEADER_H
#include <linux/linkage.h>
#include <linux/vmalloc.h>
#endif
typedef struct node{
struct node* next;
struct node* prev;
long project_pid;
long project_ticket_number;
}PROJECT_NODE;
typedef struct{
PROJECT_NODE* head;
PROJECT_NODE* tail;
int list_size;
}PROJECT_LIST;
PROJECT_LIST* project_init_list(void);
void project_add_node(PROJECT_LIST*, long);
this is my system call sample which i implemented. As you can see i had to define functions in here and prototypes are in the project_header.h which is called by two system_call files which are fork.c and sched.c
/* sample.c */
#include <linux/sample.h>
#include <linux/project_header.h>
long int maximum_ticket_number=0;
extern PROJECT_LIST* project_list;
PROJECT_LIST* project_init_list(void){
PROJECT_LIST* list = vmalloc(sizeof(*list));
list->list_size=0;
list->head = NULL;
list->tail = NULL;
return list;
}
void project_add_node(PROJECT_LIST* list, long id){
PROJECT_NODE* pnew;
pnew = vmalloc(sizeof(*pnew));
pnew->project_pid=id;
maximum_ticket_number++;
pnew->project_ticket_number=maximum_ticket_number;
if(list->list_size==0){ // Assume list is empty
list->head = pnew;
list->tail = pnew;
list->list_size++;
}
else {
list->tail->next = pnew;
pnew->prev = list->tail;
list->tail = pnew;
list->list_size++;
}
}
asmlinkage void sys_sample(void){ //System call does print the inital list size
printk("LIST->SIZE = %d\n", project_list->list_size);
return;
}
and this is the part which added into sched.c
/* sched.c */
.
.
#include <linux/project_header.h>
#include <linux/sample.h>
PROJECT_LIST* project_list; // Create a list globally
extern PROJECT_LIST* project_init_list(void); // Provide to call project_init_list function which returns a list properly
.
.
void __init sched_init(void){
.
.
project_list = vmalloc(sizeof(*project_list)); //Allocate space and initialize the variables of main list
.
.
and this is a snapshot of my current situation before kernel get started

i ‘m sure that the problem is in sched_init() function but i can’t find it. i will be very appreciated if you can help and thanks anyway.
This isn’t REALLY an answer, because this isn’t a question that can be answered with the information given. But it’s “guidance on how to find out why the kernel doesn’t start,and a bit about how the kernel starts”.
printk() is the corresponding kernel function to printf() outside of the kernel. Add that at points you think you are getting to, and places where you think it can fail, e.g. if you have “myptr = vmalloc(…);”, then
Obviously, if you are so early that the kernel proper hasn’t started and that printk may not be available, then you will need to be using out’s to the serial port will be the way to debug –
will print an ‘A’ (ascii code 65) to the serial port. Don’t hammer more than about 16 characters out at once, they will only come out at 9600 bps or some such.
By the way, the only part of the kernel where you aren’t in protected mode is for a few dozen instructions or so.
However, the virtual memory handling doesn’t start immediately, and in fact, you may find that it doesn’t work until AFTER THE SCHEDULING and the “kswapper” process has started – meaning that you can’t use vmalloc in the scheduler – I’m not certain, as this is not a part of the Linux kernel I know that well – but it may be worth looking at kmalloc instead, which is a lower level kernel functionality. Just beware that they aren’t exact replacements, so you need to look at the parameters and what they mean, and how to translate. I don’t think I’ve ever used vmalloc() in the kernel – are you sure that’s the right function to use?