My introduction, and request for a litlle help
My introduction, and request for a litlle help
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
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
Hi,
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
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.kiljacken wrote:Any help would be appreciated
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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: My introduction, and request for a litlle help
Brendan,Brendan wrote:Hi,
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.kiljacken wrote:Any help would be appreciated
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
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
On line 61 you do a Are interrupts enabled at this point ?
Code: Select all
for (;;) ;
If a trainstation is where trains stop, what is a workstation ?
Re: My introduction, and request for a litlle help
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.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
Re: My introduction, and request for a litlle help
Yes, of that I am certaingerryg400 wrote:On line 61 you do aAre interrupts enabled at this point ?Code: Select all
for (;;) ;
Yes, the thread does indeed call the "thread_exit" method, and prints out EAX.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.
I'll try playing around with volatile later, to see if that helps.
Edit: Okay, volatiles didn't help..
-
- Member
- Posts: 255
- Joined: Tue Jun 15, 2010 9:27 am
- Location: Flyover State, United States
- Contact:
Re: My introduction, and request for a litlle help
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.
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
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...
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.
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?).kiljacken wrote:but when a thread exits, the timer IRQ doesn't fire, or atleast doesn't get processed.
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.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
Re: My introduction, and request for a litlle help
Sounds crazy enough it might actually help meTosi 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.
I'll start rewriting it in the weekend.
I'll check if the Timer IRQ is the only one that doesn't fire later.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...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?).kiljacken wrote:but when a thread exits, the timer IRQ doesn't fire, or atleast doesn't get processed.
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.
Okay, now of to school with me
EDIT: Wont rewrite, takes too much time. Maybe I'll just rewrite the threading thing.