Click to See Complete Forum and Search --> : how (in general) would i implement something like this


YaRness
12-07-2000, 06:39 PM
in a traditional linear fasion, i might, in some program, issue a command to format a drive, and then pretty much just hang until the drive returns a finished status of some sort. coding something like that would be pretty simple, it might look something like


if ( format() ) then
print "format complete"
else
print "format failed"


but what if (and this is true of the SCSI bus, prolly also true of the IDE bus) when you issue a format command, the drive just returns a good status, and then formats away for x minutes until it's done, then sends another message indicating it's either done successfully or has faulted somehow.

i think hardware wise this kinda stuff is handle with interrupts, but how is something like this handled software wise? child process (which i know little about)? threads (which i don't even know what those are clearly)? i'm working on a software project in the abck of my head, and this is the first real wall i've run up against. i could really use some words of experience and stuff.

------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/
------------------

Stuka
12-07-2000, 07:16 PM
Seems to me like there are methods similar to this in non-blocking socket I/O. I don't know enough about it to tell you how it works, but I do know that w/non-blocking I/O, the send() or recv() returns immediately, then later sends some sort of signal or callback to indicate completion.

Strike
12-07-2000, 07:17 PM
The general analog for hardware interrupts in programming is signals. There's plenty of info on them out there, just dig around for "signals" and "signal handling".

YaRness
12-07-2000, 07:21 PM
woof. sounds like i'm over my head. s'ok, i got nothin but the rest of my life to diddle around with it. thanks for the info.

------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/
------------------

pdc
12-08-2000, 02:36 AM
You could find some examples in your linux src tree, methinks. Probably not trivial. Maybe you could issue the command and then another scsi command to ask how the drive is doing i.e. check its state and see if the format does some "I'm busy, go away" rc, then loop on that.
Paul

YaRness
12-08-2000, 08:54 AM
one of the scripts/programs(?) we use does something like that, during the format, you can hit a key to send a request sense to the drive, and it returns basically that it's not done... it might give some indication as to how much it has done so far, i'm not sure. but when the drive IS done formatting, the script continues on to the next part. i'm not sure if it just polls the drive until it's done, or if it somehow keeps an ear on the bus to listen for when the drive signals that it's done.

------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/
------------------