This blog will follow the creation of DGOS. My operating system for mobile devices. It is currently being developed on a Palm LifeDrive. I will post here interesting pieces of code, ideas, or design decisions.
Today's post shows how easy it is to drive device drivers in DGOS. This is the COMPLETE source code for the hard drive driver in the LD. Note a complete lack of synchronization primitives, or anything else. The OS handles that for the driver.
Note that the only entry point into the driver is "hddInit"
Requests and responses are handled by the "requestQ" primitive. It is smart, blocking the driver thread while waiting for requests and blocking requesting threads while waiting for responses. While this driver is single-threaded, multithreaded drivers can use it too, since this primitive is thread-safe.