I'm a fourth year Computer Engineering student, and I'm taking a class on operating systems. Our school places a great emphasis on Java, so we have a course project to make a Java operating system. We're not doing any low level stuff - no JVM mods to run on hardware, it's basically emulation - using the language to control threads and provide very basic input/output for text commands. We are trying to implement a Unix-like OS with similar programs (ps, kill, etc.).
Anyhow, the first part of the project went well, but the second part was pretty much a disaster... We had to implement a scheduler that would wake up and run threads for a certain time given their priority, plus a "MemorySucker" that would eat into our "memory". As far as I've been able to tell from Java's API, there's no ready-made methods to suspend and resume threads... at least not ones which aren't deprecated. That might have been part of the problem, I'm just not quite sure. I used a circular list to keep track of my running threads, but everytime I'd call a program (thread) that did not automatically kill itself after executing, I might be able to call another program once more and have it work, and then nothing would work - it's either the list or that fact that I'm using deprecated methods to suspend/resume threads. The project has gotten a bit hairy (big) and it's getting hard for me to keep track of where things are happenning. I'm also not very familiar with the debugger, and it's quite a pain to debug such a complex project one thing at a time. I'm pretty sure posting a .zip with the project wouldn't do much, as nobody'd download an unknown file from an unknown poster (at least, I'd hope, for the sake of security!). So I'll post the code tomorrow... it's almost 4am where I'm at right now. But anyways, here's a few preliminary questions I have:
1) Is there a standard, reliable way of suspending/resuming threads in Java? I saw the API's explanation, and implemented their solution for stop() on my scheduler, but I'm still not clear as to the suspend/resume methods.
2) For purposes of a Java OS, should I implement all programs as runnables or directly as threads? Is there an advantage to one or the other?
3) I've been looking a bit through the API, to see if I can find other implemented classes which can help me.
Are there any specific classes, apart from Thread and Runnable, which might help me with this project?
Any help would be greatly appreciated.