Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Edit the incomplete C source code to create a linked list to store the birthday information of 5 random students . For each person, the

Edit the incomplete C source code to create a linked list to store the birthday information of 5 random students . For each person, the birthday information should include month, day, year, and name. When the module is loaded, traverse through the linked list and output its content to the kernel log buffer. In addition, write code to identify the oldest student and remove that student from the list. After removing the oldest student, output the updated linked list content to the kernel log buffer.

This is the code I have so far. I need the delete_Oldest to be implemented. It should traverse the linklist and delete the oldest and then output the list content to the kernel log buffer. I have already done the linklist traversal I just need the delete_Oldest method. THANKS!

CODE:

struct birthday

{

int day;

int month;

int year;

char[] name;

// this struct contains two members prev and next that point to the next and previous entries in the list

struct list_head list;

};

static LIST_HEAD(birthday_list);

int simple_init(void)

{

printk(KERN_INFO "Loading Module ");

struct birthday *jim;

jim = kmalloc(sizeof(*jim), GFP_KERNEL);

jim->day = 10;

jim->13;

jim->year = 1994;

INIT_LIST_HEAD(&jim->list);

list_add_tail(&jim->, &birthday_list);

struct birthday *bobby;

bobby = kmalloc(sizeof(*bobby), GFP_KERNEL);

bobby->day = 11;

bobby->12;

bobby->year = 1993;

INIT_LIST_HEAD(&bobby->list);

list_add_tail(&bobby->, &birthday_list);

struct birthday *tommy;

tommy = kmalloc(sizeof(*tommy), GFP_KERNEL);

tommy->day = 9;

tommy->12;

tommy->year = 1992;

INIT_LIST_HEAD(&tommy->list);

list_add_tail(&tommy->, &birthday_list);

struct birthday *smith;

smith = kmalloc(sizeof(*smith), GFP_KERNEL);

smith->day = 8;

smith->20;

smith->year = 1991;

INIT_LIST_HEAD(&smith->list);

list_add_tail(&smith->, &birthday_list);

struct birthday *james;

james = kmalloc(sizeof(*james), GFP_KERNEL);

james->day = 7;

james->31;

james->year = 1990;

INIT_LIST_HEAD(&james->list);

list_add_tail(&james->, &birthday_list);

struct birthday *ptr;

// ptr - pointer to the structure thats being iterated over

// &birthday_list - a pointer to the head of the list being iterated over

// list - the name of the variable containing the list_head structure

list_for_each_entr(ptr, &birthday_list, list)

{

printk(KERN_INFO "Birthday: Month: %d Day: %d Year: %d ",

ptr->month,

ptr->day,

ptr->year);

return 0;

}

// Please complete according to the requirements above

void delete_Oldest(void)

{

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions