Async Requests for Devices

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Jeko
Member
Member
Posts: 500
Joined: Fri Mar 17, 2006 12:00 am
Location: Napoli, Italy

Async Requests for Devices

Post by Jeko »

Which is a good method to handle async requests? Can you give me some advices?
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

In my old kernel I used threads for requests, which allowed asynchronous execution. The biggest thing you must look out for when using threads is locking resources (such as the mount table) when using them ;).
User avatar
Jeko
Member
Member
Posts: 500
Joined: Fri Mar 17, 2006 12:00 am
Location: Napoli, Italy

Post by Jeko »

I have only few questions:
1 - When a task dies, must I cancel all his requests?
2 - When a task dies, must I clear all his handles?
3 - When a fs is unmounted, must I clear all handles to it?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

3 - When a fs is unmounted, must I clear all handles to it?
Do you even want to unmount it when it's being accessed?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
froseph
Posts: 3
Joined: Sun Apr 13, 2008 3:05 pm

Post by froseph »

1 - When a task dies, must I cancel all his requests?
2 - When a task dies, must I clear all his handles?
3 - When a fs is unmounted, must I clear all handles to it?
Basic software engineering:

1 - What will happen if you don't?
2 - What will happen if you don't?
3 - What will happen if you don't?

In general, what are the consequences of choosing to do it one way or the other?

Just trying to lead you to an answer.
User avatar
Jeko
Member
Member
Posts: 500
Joined: Fri Mar 17, 2006 12:00 am
Location: Napoli, Italy

Post by Jeko »

Combuster wrote:
3 - When a fs is unmounted, must I clear all handles to it?
Do you even want to unmount it when it's being accessed?
If for example the user take out the cdrom, /media/cdrom must be unmounted and all handles to it must be cancelled. Or not?
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post by bewing »

Both/neither. If the user takes out the media, and a program still tries to access it, you ask the user to put the media back -- along with a button that says "unmount". If the user hits the "unmount" button -- then you unmount that partition. And let the program deal with an error exit from the "read" function.
User avatar
Jeko
Member
Member
Posts: 500
Joined: Fri Mar 17, 2006 12:00 am
Location: Napoli, Italy

Post by Jeko »

bewing wrote:Both/neither. If the user takes out the media, and a program still tries to access it, you ask the user to put the media back -- along with a button that says "unmount". If the user hits the "unmount" button -- then you unmount that partition. And let the program deal with an error exit from the "read" function.
so handles mustn't be deleted. So I must check if a handle is valid each time it's used...
iammisc
Member
Member
Posts: 269
Joined: Thu Nov 09, 2006 6:23 pm

Post by iammisc »

Do it however you want. It really isn't that hard. We can't make design decisions for you. You need to make them yourself(this is your OS not ours). like froseph said, what will happen if you don't?

bewing gave you one example of what you could do but you could also simply refuse to let the drive be ejected. However, you could also simply return all errors for the read() function. In addition, you could have a whole subsystem that deals with notifying programs when removable media is ejected.

My point is that there are many ways to handle all the things you asked and there is no right way to do it. No matter what way you chose, it will be right for your OS(albeit it might not be as robust as other ideas but that doesn't make it wrong).
Post Reply