: : : : Why would anyone want to have a circular linked list?
: : : :
: : : : As I see it it would only make the code more complex and less efficient.
: : : :
: : :
may be this is part of an assignment?
not bad though.
: : :
: : :
~Donotalo()
: : :
: : :
: :
: : As Mr. Donotalo stated " this is part of an assignment? ". I have an operating systems course and i am supposed to do all coding with C. In this assignment i must use linked lists.
: :
: : Anyway thanx for your help guys
: :
: : Best Regards
: : Abdul Hameed
: :
:
: But that doesn't explain why you should use a circular list, it's just plain ineffiecient and dumb.
: There're no benefit of using a circular list instead of a plain linked list.
:
: So why are you using such a dumb design in an OS then?
:
In this assignment we have the choice for chosing any data structure we prefer. I said that CSLL might be helpful and easier to dear with, but I think I will use only plain SLL instead of CSLL. The following is the assignment doc.
***********************************************
Project Title:
Mailbox Abstraction Library
Project Objective:
- To demonstrate your understanding of Thread Creation and Execution concept.
- To demonstrate your understanding of Thread synchronization
- (Optionally) How to compile my project using make utility.
********* The Assignment *******************
This assignment is to be written in the C programming language. You will implement a mailbox abstraction that has the following functions (see below). You should define a mailbox type (mailbox_t) and pass it as the first parameter to each of the functions. The prototypes for the mailbox abstraction are as follows:
mailbox_t * create_mailbox (int mailbox_size)
Allocate and initialize a new mailbox that can hold at most mailbox_size.
void put_message (mailbox_t *mb, void *item) Add item to the end of the mailbox. If the mailbox queue already contains mailbox_size, the put operation should block the calling thread until there is room in the mailbox.
void *get_message (mailbox_t *mb)
Remove the first item from the mailbox and return that item. If the mailbox is empty, the calling thread shou!ld block.
void *read_head(mailbox_t *mb)
Return head of mailbox without removing the item. This function should return NULL if the queue is empty.
int probe (mailbox_t *mb)
Test if the mailbox contains an item. It will return true if the mailbox is not empty.
Implementation Requirements
The entire implementation should be in the file mailbox.c. You may NOT change the existing functions parameters or return types. A header file named mailbox.h is required to declare the mailboxs type and all the function prototypes.
You also have to write a test program named testmail.c that contains the main function. The test program that you write should create two new threads and one mailbox. The first thread should put the numbers 1..10 into the mailbox queue, and the second thread should remove the items and print them out as they are removed. When you create the mailbox, it should have a maximum of 5 items. You should also test other features of your program. When we test your program, we will substitute our own version of testmail.c with additional test cases.
*********************************************************
Regards