My OS Design
Posted: Sat Nov 25, 2006 10:02 am
Hi,all.
This is my first post here,and if you're not interested in my introduction,please skip the next paragragh.
I'm a senior school student from China.I'm interested in several programming fields and especially on fire for OS development.I've been watching this site for long.However,under the pressure from China's examination-oriented education mechanism,usually I don't have much time for my development and I used to visit this site as a guest.This is my first post after my registration.Thanks a lot to everyone here,for I've benefitted a lot here.I'm glad that we can communicate with each other from now on.
I started my own OS project long before which is still under construction.I focus so much on the development that I haven't named my OS yet.
Here I want to introduce some main ideas in my OS core.(Some of the similar ideas may have existed already,but please read the following text according to the context.Some definitions and algorithms will come first and the situation in my OS will be specified after them.)
Variable Types
All variables can be either of the 2 types:the Static Variable(SV) and the Dynamic Variable(DV).An SV here refers to a variable with constants only,while a DV refers to a variable with other variables in its expression.For instance,x,y and z are all variables,and x=3,y=x*6 and z=x^2.
Among them x is an SV and both y and z are DVs.
NOTE:the SV is different from the constant in NASM,as a variable's expression can be modified during runtime.In fact,a variable can change its type in this way.
Dynamic Computation Deck(DCD)
the DCD is the environment where the 2 types of variables mentioned above exist during runtime.It's named so because the variables in it can stay "live".Anytime when the value of a variable is wanted(read) by other variables or I/O modules,it's the DCD's mission to return the most updated(sychronized) value of the wanted(read) variable.This is only for the DVs.
For instance,x,y and z are all variables,and x=y*3+7,y=z/5 and z=8,thus y=1.6 and x=11.8.If z is increased by 1(z=9) at some time during runtime,the DCD will update x and y in time so that y=1.8 and x=12.4.Furthermore,if x or y is in the expressions of other DVs such as a DV named w,w will be updated in time as well,etc.,just like a updating chain.
How It Is Implemented(the Algorithm)
The algorithm isn't very complicated but it may be a little difficult to achieve.
When initialized,every variable(both the DV and the SV) is allocated a Notification List(NL) containing the names(not the values or the expressions) of those DVs which have its reference in their expressions.If the value of a variable is modified,the DCD will update all the DVs on the NL of the modified one in time.
However,we have a problem:in the implementation on a real CPU,only one DV can be updated by the DCD at one time.So the Context Queue(CQ) is needed,which holds the DVs that should be updated logically at the same time.When the current DV has been updated,a certain(perhaps not the head one,the reason will be described below) DV at the head of the CQ will be updated.We also need a system parameter called Maximum Delay Number(MDN).This would be useful in such a situation:the same DV appears on the NL more than once.Obviously,to update it in such a short time(at the same logical time)is a waste of time.So if a DV comes to the head of the CQ,the DCD will check if the following MDN items(counted from the 2nd one) in the CQ contain the same DV as the one at the head.If they do,then the DV at the head will be deleted and the DCD will update this DV when the last detected same DV in the first MDN items comes to the head of the CQ(currently the DCD will deal with the one follwing the deleted one),or else the current DV will be updated immediately.
For instance,t,u,v,w,x,y and z are variables,and u=2,v=3,x=3,t=u+v,w=u*x,y=t-u and z=t-9,thus t=5,w=6,y=3 and z=-4.The CQ is set empty and the MDN equals 5.
We can describe the variables NLs as folowing:t(u,v),w(u,x),y(t,u),z(t).The variables in the brackets are the NL items of the variables before the brackets.Suppose u is modified and its current expression is u=v(u=3 currently),then the following events will occrur in the specified order:
1.Because of the fact t(u,v),w(u,x) and y(t,u),both t,w and y should be updated immediately at the same logical time.For the reason mentioned in the paragraph above,the System Scheduler(SS) will select either of them to update.Suppose t is selected,then w and y are put into the CQ(w first).The current CQ is like this:[w,y](The left side is the head).Now t is updated.
2.Because of t's updating and the fact y(t,u) and z(t),y and z should be updated right now.But w is the current head of the CQ,so y and z are put into the CQ.w is deleted from the CQ and is updated.The current CQ is like this:[y,z,y](suppose z was put into the CQ before y according to the SS's decision)
3. The DCD finds y is the head of the queue,follow by a z with another y behind.The second y is now the 3rd item of the CQ.As (3-1)<MDN,the 1st y(which is the head) will be deleted and the DCD will update the 2nd y,after z is updated.So the CQ has changed in such an order:[z,y],[y],[].
So the result should be:u=3,v=3,x=3,t=6,w=9,y=3 and z=-3.
Other Features That May Infuence the Algorithm
In order to prevent one variable's calculation's taking up too much time,I combine this algorithm with some other multitasking mechanisms such as the Round-Robin.And in order to make the algorithm more effective,the DVs should be updated only when it's being wanted by other DVs which are being wanted,or it's being wanted(read) by the I/O modules or the users or something else.The phrase "in time" used above just refers to this.
The Scope of My Implementation
The 2 types of variables(the SV and the DV) are one kind of runtime object in my OS,namely the Idx[Calc.](Idx is short for Index,and there're 3 types of Idxes in my OS,they are similar to the thread but still have difference.I'll post later to specify them in detail).It has a serial code(like the expression,however,it's binary code) and an external data(like the value) basically.
In summary,the DV is a little like the function returning value in C,but it's scheduled dynamically to achieve the sychronization(updating).
This post mainly contains the basic theory of the most important ideas in my OS core.I'll post later to show you more description about the detailed things in my OS,mainly on the Idx.
I really want to hear your voice on this post,no matter you support my ideas or not.All comments are always welcomed.And you can contact me by E-mail if you want.
Thanks in advance if you can read it and reply.
This is my first post here,and if you're not interested in my introduction,please skip the next paragragh.
I'm a senior school student from China.I'm interested in several programming fields and especially on fire for OS development.I've been watching this site for long.However,under the pressure from China's examination-oriented education mechanism,usually I don't have much time for my development and I used to visit this site as a guest.This is my first post after my registration.Thanks a lot to everyone here,for I've benefitted a lot here.I'm glad that we can communicate with each other from now on.
I started my own OS project long before which is still under construction.I focus so much on the development that I haven't named my OS yet.
Here I want to introduce some main ideas in my OS core.(Some of the similar ideas may have existed already,but please read the following text according to the context.Some definitions and algorithms will come first and the situation in my OS will be specified after them.)
Variable Types
All variables can be either of the 2 types:the Static Variable(SV) and the Dynamic Variable(DV).An SV here refers to a variable with constants only,while a DV refers to a variable with other variables in its expression.For instance,x,y and z are all variables,and x=3,y=x*6 and z=x^2.
Among them x is an SV and both y and z are DVs.
NOTE:the SV is different from the constant in NASM,as a variable's expression can be modified during runtime.In fact,a variable can change its type in this way.
Dynamic Computation Deck(DCD)
the DCD is the environment where the 2 types of variables mentioned above exist during runtime.It's named so because the variables in it can stay "live".Anytime when the value of a variable is wanted(read) by other variables or I/O modules,it's the DCD's mission to return the most updated(sychronized) value of the wanted(read) variable.This is only for the DVs.
For instance,x,y and z are all variables,and x=y*3+7,y=z/5 and z=8,thus y=1.6 and x=11.8.If z is increased by 1(z=9) at some time during runtime,the DCD will update x and y in time so that y=1.8 and x=12.4.Furthermore,if x or y is in the expressions of other DVs such as a DV named w,w will be updated in time as well,etc.,just like a updating chain.
How It Is Implemented(the Algorithm)
The algorithm isn't very complicated but it may be a little difficult to achieve.
When initialized,every variable(both the DV and the SV) is allocated a Notification List(NL) containing the names(not the values or the expressions) of those DVs which have its reference in their expressions.If the value of a variable is modified,the DCD will update all the DVs on the NL of the modified one in time.
However,we have a problem:in the implementation on a real CPU,only one DV can be updated by the DCD at one time.So the Context Queue(CQ) is needed,which holds the DVs that should be updated logically at the same time.When the current DV has been updated,a certain(perhaps not the head one,the reason will be described below) DV at the head of the CQ will be updated.We also need a system parameter called Maximum Delay Number(MDN).This would be useful in such a situation:the same DV appears on the NL more than once.Obviously,to update it in such a short time(at the same logical time)is a waste of time.So if a DV comes to the head of the CQ,the DCD will check if the following MDN items(counted from the 2nd one) in the CQ contain the same DV as the one at the head.If they do,then the DV at the head will be deleted and the DCD will update this DV when the last detected same DV in the first MDN items comes to the head of the CQ(currently the DCD will deal with the one follwing the deleted one),or else the current DV will be updated immediately.
For instance,t,u,v,w,x,y and z are variables,and u=2,v=3,x=3,t=u+v,w=u*x,y=t-u and z=t-9,thus t=5,w=6,y=3 and z=-4.The CQ is set empty and the MDN equals 5.
We can describe the variables NLs as folowing:t(u,v),w(u,x),y(t,u),z(t).The variables in the brackets are the NL items of the variables before the brackets.Suppose u is modified and its current expression is u=v(u=3 currently),then the following events will occrur in the specified order:
1.Because of the fact t(u,v),w(u,x) and y(t,u),both t,w and y should be updated immediately at the same logical time.For the reason mentioned in the paragraph above,the System Scheduler(SS) will select either of them to update.Suppose t is selected,then w and y are put into the CQ(w first).The current CQ is like this:[w,y](The left side is the head).Now t is updated.
2.Because of t's updating and the fact y(t,u) and z(t),y and z should be updated right now.But w is the current head of the CQ,so y and z are put into the CQ.w is deleted from the CQ and is updated.The current CQ is like this:[y,z,y](suppose z was put into the CQ before y according to the SS's decision)
3. The DCD finds y is the head of the queue,follow by a z with another y behind.The second y is now the 3rd item of the CQ.As (3-1)<MDN,the 1st y(which is the head) will be deleted and the DCD will update the 2nd y,after z is updated.So the CQ has changed in such an order:[z,y],[y],[].
So the result should be:u=3,v=3,x=3,t=6,w=9,y=3 and z=-3.
Other Features That May Infuence the Algorithm
In order to prevent one variable's calculation's taking up too much time,I combine this algorithm with some other multitasking mechanisms such as the Round-Robin.And in order to make the algorithm more effective,the DVs should be updated only when it's being wanted by other DVs which are being wanted,or it's being wanted(read) by the I/O modules or the users or something else.The phrase "in time" used above just refers to this.
The Scope of My Implementation
The 2 types of variables(the SV and the DV) are one kind of runtime object in my OS,namely the Idx[Calc.](Idx is short for Index,and there're 3 types of Idxes in my OS,they are similar to the thread but still have difference.I'll post later to specify them in detail).It has a serial code(like the expression,however,it's binary code) and an external data(like the value) basically.
In summary,the DV is a little like the function returning value in C,but it's scheduled dynamically to achieve the sychronization(updating).
This post mainly contains the basic theory of the most important ideas in my OS core.I'll post later to show you more description about the detailed things in my OS,mainly on the Idx.
I really want to hear your voice on this post,no matter you support my ideas or not.All comments are always welcomed.And you can contact me by E-mail if you want.
Thanks in advance if you can read it and reply.