dreamos82 / DreamOs

A small 32 bit Operating system written from scratch
GNU General Public License v3.0
62 stars 16 forks source link

Tasklist and thread fixes #50

Closed ghost closed 7 years ago

ghost commented 7 years ago

Implemented back the tasklist and fixed current_thread (thread.c). TODO: soon we will need to implement the self kill thread to stop all terminating ones.

ghost commented 7 years ago

There is a global variable named current_thread in thread.c. There was a global variable current_thread (thread_list_t *) also in scheduler.c. It is required to disambiguate because i added in switch_thread (thread_asm.s) code to update the current_thread (thread.c). Without doing this, the current_thread in thread.c isn't updated so it is impossible to access thread info. Cmd field is a way to add an information already passed to the function kernel_create_thread (arg variable in stack). Why pass an information about thread cmd and not store it in the thread to use it? If you don't want it then remove arg parameter in kernel_create_thread you added in the code.

Printing the thread in thread_exit is a test that current_thread variable is updated correctly, i needed it to test nasm working correctly.

Numerio commented 7 years ago

I see. Before all try to explain clearly what you've done, no one had clue looking at the message.

The asm code is obviously trying to access a thread_t so, on a first look, it seems one of the two vars should go away. However the current_thread in threads.c is not used for anything. So it's just more smart to memorize in scheduler.c a thread_t called current_thread and it's thread_list_t in another one called current_thread_list. You can set anyway the latter one from c.

The arg is already set in the stack, there's no need to access it or set another var to print a name.

Numerio commented 7 years ago

The properly "fixes" are now in master.