Some months ago I wrote some floppy disk routines with the follow services:
1) init() --> Initialize the floppy system.
2) motor_control() --> Turn on/off motor.
3) read_sector() --> Read one sector.
4) write_sector() --> Write one sector.
Now I am working in my Operating System 'File System' and I must use these routines, but I realize that is very tedious turn on/off the floppy motor each time I need read/write sectors (and it make my code some complex).
How must be handled the floppy motors?
It is right let the user turn on/off the floppy motors?
Is better let the floppy disk driver to do it?
Thank you very much,
pepito
(sorry my poor english)
Floppy disk driver problem
RE:Floppy disk driver problem
No, I wouldn't give the user access to turn on/off the floppy motor.
The best approach, in my opinion, is to have a floppy motor thread. When you want to read/write a sector, you tell this thread to enable the motor.
The thread checks if the motor is already running, if not, it starts it, and then starts a countdown. After, say, 15 seconds of no activity, the floppy motor is turned off again.
In other words, every one of your disk accesses will enable the motor... but... this isn't really an expensive operation, because the motor is already running 95% of the time. Don't let anything turn the floppy motor off but the "motor thread" and you're all set.
Hope that makes sense!
Cheers,
Jeff
The best approach, in my opinion, is to have a floppy motor thread. When you want to read/write a sector, you tell this thread to enable the motor.
The thread checks if the motor is already running, if not, it starts it, and then starts a countdown. After, say, 15 seconds of no activity, the floppy motor is turned off again.
In other words, every one of your disk accesses will enable the motor... but... this isn't really an expensive operation, because the motor is already running 95% of the time. Don't let anything turn the floppy motor off but the "motor thread" and you're all set.
Hope that makes sense!
Cheers,
Jeff