views:

33

answers:

1

my lecture wants us to build module where we need to identify each read process and where the same read process called twice on the same writer massage we should insert him to an queue who's we wake up when all readers have read I achieved this goal by by using list of pid's and boolean read/not_read inside each node but he decided to be nasty and require us to it with some argument from FILE struct can you please help me ?....

A: 

The key concept here is that you should not be directly identifying processes - you should be identifying particular struct files. A new struct file is created each time your file is open()-ed.

In fact you do not need to add any data to the struct file at all - you could just turn your list of PIDs into a list of struct file *s, pointing at the struct files that currently have your special file open.

It would, however, be more efficient to have the private_data pointer of the struct file point at the node in your list that contains a pointer to that struct file (this will enable you to find that node quickly when you are working with it, rather than having to scan the list).

caf