OSDev.org

The Place to Start for Operating System Developers
It is currently Thu May 16, 2024 6:02 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Async Requests for Devices
PostPosted: Thu Apr 10, 2008 8:15 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 17, 2006 12:00 am
Posts: 500
Location: Napoli, Italy
Which is a good method to handle async requests? Can you give me some advices?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 10, 2008 6:16 pm 
Offline
Member
Member

Joined: Sun Jan 14, 2007 9:15 pm
Posts: 2566
Location: Sydney, Australia (I come from a land down under!)
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 ;).

_________________
Pedigree | GitHub | Twitter | LinkedIn


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 10:28 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 17, 2006 12:00 am
Posts: 500
Location: Napoli, Italy
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?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 10:41 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
Quote:
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 ]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 10:41 am 
Offline

Joined: Sun Apr 13, 2008 3:05 pm
Posts: 3
Quote:
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.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 11:16 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 17, 2006 12:00 am
Posts: 500
Location: Napoli, Italy
Combuster wrote:
Quote:
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?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 11:24 am 
Offline
Member
Member
User avatar

Joined: Wed Feb 07, 2007 1:45 pm
Posts: 1401
Location: Eugene, OR, US
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.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 11:32 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 17, 2006 12:00 am
Posts: 500
Location: Napoli, Italy
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...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 5:39 pm 
Offline
Member
Member

Joined: Thu Nov 09, 2006 6:23 pm
Posts: 269
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).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot], SemrushBot [Bot] and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group