Posted 27 July 2015 - 07:07 AM
I'm looking to start making an operating system, and I'm planning out a lot of the things I want, and I am looking over my broad idea again, and realizing how flawed it is:
I am planning on having the operating system resume coroutines which will update individual programs, but the problem would be that this approach heavily necessitates each sub-program to yield in each loop.
I was wondering if anyone had any recommendations to replace this scheme so that the operating system actually serves as the master, and doesn't depend on each program to work perfectly.
Here's a brief example of how the current plan would work:
(If I've made any mistakes in syntax or setup, don't worry, I am really only concerned with big picture right now)
I am planning on having the operating system resume coroutines which will update individual programs, but the problem would be that this approach heavily necessitates each sub-program to yield in each loop.
I was wondering if anyone had any recommendations to replace this scheme so that the operating system actually serves as the master, and doesn't depend on each program to work perfectly.
Here's a brief example of how the current plan would work:
--Define the different programs as coroutines, which could be turned on by the master
c1 = coroutine.wrap(
--Program 1
while true do
doUpdateStuff()
coroutine.yield() --If this line is missing or for whatever reason it is not called, worst case scenario is this program seizes control of the entire computer
end
)
c2 = coroutine.wrap(
--Program 2
while true do
doUpdateStuff()
coroutine.yield() --
end
)
c3 = coroutine.wrap(
--Program 3
while true do
doUpdateStuff()
coroutine.yield() --
end
)
--Master/OS part:
while true do
coroutine.resume(c1)
coroutine.resume(c2)
coroutine.resume(c3)
UpdateEverythingWithAllProgramsConsidered()
end
(If I've made any mistakes in syntax or setup, don't worry, I am really only concerned with big picture right now)
Edited on 27 July 2015 - 03:43 PM