Find the answer to your Linux question:
Results 1 to 2 of 2
hi there i'm a newbie about kernel programming and i have to do a project about changing some stuff on linux scheduler function. Moreover, i want to use a linked ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2012
    Posts
    3

    how to use linux's own linked list implementation globally


    hi there i'm a newbie about kernel programming and i have to do a project about changing some stuff on linux scheduler function. Moreover, i want to use a linked list for being more clear rather than an array. However, i 'm facing with some problems about using a linked list globally which derived from kernel's own linked list implementation. First of all, i read this simple document to start progress.

    Code:
    kernelnewbies.org/FAQ/LinkedLists
    now i hope i will be clear to you. First, i defined a header file (
    Code:
    project_header.h
    )

    in
    Code:
    /usr/src/linux-2.4.20/include/linux
    directory which contains the data structure i will use and the code is like this.

    Code:
    #ifndef __LINUX_PROJECT_HEADER_H
    
    #define __LINUX_PROJECT_HEADER_H
    
    #include <linux/linkage.h>
    #include <linux/vmalloc.h>
    #include <linux/list.h>
    
    #endif
    
    typedef struct node{
    
            struct list_head mylist; /* kernel's list structure */
            long int project_pid;
            long project_ticket_number;
    
    }NODE;
    secondly, i defined my own system call file
    Code:
    sample.c
    in
    Code:
    /usr/src/linux-2.4.20/fs
    directory and this .c contains

    Code:
    #include <linux/sample.h>
    #include <linux/project_header.h>
    
    long int maximum_ticket_number=0;
    
    LIST_HEAD(mylinkedlist) ; //to represent the start (head) of our list
    
    asmlinkage void sys_sample(void){
    
            NODE* temp=NULL;
            struct list_head* position = NULL;
    
            list_for_each(position, &mylinkedlist){
    
                    temp = list_entry(position, NODE, mylist);
                    printk("data = %ld\n", temp->project_pid);
            }
    
            return;
    }
    so my main question is how i can use or call this main linked list (mylinkedlist) in fork.c and sched.c. or how i suppose to define mylinkedlist ?

    i hope i been clear and understandable to you and i will be very glad if you can help me and thanks anyway...

  2. #2
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,743
    I don't know the answer I hope some other member will reply btw, have you posted the question in kernelnewbies.org mailing list? That's excellent resource for kernel newbies
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •