Page 1 of 1
My introduction, and request for a litlle help
Posted: Mon Mar 14, 2011 12:29 pm
by kiljacken
Hi,
My name is Emil, I'm 14 years old, and very interested in OS development.
I am working on my own OS based on the code from JamesM's kernel tutorial code on googlecode (code.google.com/p/jamesm-tutorials/),
but I have encountered a problem.
The kernel supports multithreading, but when a thread exits, the timer IRQ doesn't fire, or atleast doesn't get processed.
My code is on github:
https://github.com/kiljacken/EmilOS
Any help would be appreciated
Edit: The main kernel file, is src/main.c, the threading stuff is in src/threading.c and src/scheduler.c, and the timer IRQ stuff is handled in src/timer.c
Re: My introduction, and request for a litlle help
Posted: Mon Mar 14, 2011 8:31 pm
by Brendan
Hi,
kiljacken wrote:Any help would be appreciated
Have you ever done first-aid training? Usually (for the resuscitation part) they bring out a special plastic dummy for you to practice on. It doesn't matter how good you are at resuscitation, that plastic dummy will never get up, get a job and lead a normal life.
Code designed for a tutorial is little bit like that plastic dummy. It's designed to illustrate concepts and to make it easier to see/understand basic principles. It's not designed to be actually useful in a real OS.
Cheers,
Brendan
Re: My introduction, and request for a litlle help
Posted: Tue Mar 15, 2011 12:32 am
by kiljacken
Brendan wrote:Hi,
kiljacken wrote:Any help would be appreciated
Have you ever done first-aid training? Usually (for the resuscitation part) they bring out a special plastic dummy for you to practice on. It doesn't matter how good you are at resuscitation, that plastic dummy will never get up, get a job and lead a normal life.
Code designed for a tutorial is little bit like that plastic dummy. It's designed to illustrate concepts and to make it easier to see/understand basic principles. It's not designed to be actually useful in a real OS.
Cheers,
Brendan
Brendan,
I do indeed know that it is based tutorial code, and it isn't made for the next big OS, but I have gone through all the code, and it should work, it just doesn't and I don't understand it.
I know exactly where it happens, I just can't see why.
If anybody has anything to contribute to this thread, I would be more than happy to listen.
A little more info, is that it happens here:
https://github.com/kiljacken/EmilOS/blo ... c/thread.c on line 62, when it enters an infinite loop. Could a garbage cleaning syscall, that removes it from existence, help here maybe?
Please tell my your opinion on this problem
Re: My introduction, and request for a litlle help
Posted: Tue Mar 15, 2011 2:54 am
by gerryg400
On line 61 you do a
Are interrupts enabled at this point ?
Re: My introduction, and request for a litlle help
Posted: Tue Mar 15, 2011 3:19 am
by Creature
Are you sure it actually reaches thread_exit (i.e. is the EAX value actually printed using printk)? Also, as you are working in multiple threads with different stacks, you may want to make some of the variables, such as ready_queue, 'volatile' so the compiler doesn't assume the value hasn't changed.
Re: My introduction, and request for a litlle help
Posted: Tue Mar 15, 2011 10:47 am
by kiljacken
gerryg400 wrote:On line 61 you do a
Are interrupts enabled at this point ?
Yes, of that I am certain
Creature wrote:Are you sure it actually reaches thread_exit (i.e. is the EAX value actually printed using printk)? Also, as you are working in multiple threads with different stacks, you may want to make some of the variables, such as ready_queue, 'volatile' so the compiler doesn't assume the value hasn't changed.
Yes, the thread does indeed call the "thread_exit" method, and prints out EAX.
I'll try playing around with volatile later, to see if that helps.
Edit: Okay, volatiles didn't help..
Re: My introduction, and request for a litlle help
Posted: Tue Mar 15, 2011 3:44 pm
by Tosi
I would recommend rewriting everything from scratch without following any tutorial, but that's just me.
You would be surprised how easy it is to get things working when you have written every line of code yourself.
Re: My introduction, and request for a litlle help
Posted: Tue Mar 15, 2011 9:19 pm
by Chandra
I'd agree with Tosi in this case. If you write you own code, it's easy to understand how things are organized. One thing of which I'm sure is - you are not going to follow our suggestions at this moment (or at least, not unless you resolve this problem). So a little help on the way...
kiljacken wrote:but when a thread exits, the timer IRQ doesn't fire, or atleast doesn't get processed.
Is it only Timer IRQ that doesn't fire or other interrupts as well? If the other interrupts don't fire as well, then it might help to see if interrupts are actually enabled. Or at least, if EOI has been sent to the
Interrupt Controller(unlikely?).
If it is only the Timer IRQ that doesn't fire, then you may want to mask the Timer IRQ then unmask it, to see if it actually brings any change.
Re: My introduction, and request for a litlle help
Posted: Wed Mar 16, 2011 12:35 am
by kiljacken
Tosi wrote:I would recommend rewriting everything from scratch without following any tutorial, but that's just me.
You would be surprised how easy it is to get things working when you have written every line of code yourself.
Sounds crazy enough it might actually help me
I'll start rewriting it in the weekend.
Chandra wrote:I'd agree with Tosi in this case. If you write you own code, it's easy to understand how things are organized. One thing of which I'm sure is - you are not going to follow our suggestions at this moment (or at least, not unless you resolve this problem). So a little help on the way...
kiljacken wrote:but when a thread exits, the timer IRQ doesn't fire, or atleast doesn't get processed.
Is it only Timer IRQ that doesn't fire or other interrupts as well? If the other interrupts don't fire as well, then it might help to see if interrupts are actually enabled. Or at least, if EOI has been sent to the
Interrupt Controller(unlikely?).
If it is only the Timer IRQ that doesn't fire, then you may want to mask the Timer IRQ then unmask it, to see if it actually brings any change.
I'll check if the Timer IRQ is the only one that doesn't fire later.
Okay, now of to school with me
EDIT: Wont rewrite, takes too much time. Maybe I'll just rewrite the threading thing.