[NSWI004] Context switch
LubomÃr Bulej
bulej at d3s.mff.cuni.cz
Mon Nov 9 16:22:39 CET 2020
Hi,
I'm just replying here to mark this particular issue as solved.
It turns out the problem was due to wrong stack pointer initialization and
subsequent stack overflow.
Don't forget that the stack needs to "grow" from *higher* addresses towards
*lower* addresses, while the pointer returned by kmalloc() points at the
*lowest* address of a memory block.
Other comments I made while looking at their code, which might be useful to
others:
- make sure to extract low-level code into functions, i.e., unless a function
is named "strcpy" or anything that resembles copying of strings, there
should be no loop walking over a string
- similar things apply to code performing pointer alignment, i.e., no matter
how you do it (be it loops with modulo test, or smart bit operations), the
actual details have no place in "business" code
- scheduler should not call cpu_switch_context(), it should call the
thread_switch_to() function to switch to another thread
Best regards,
Lubomir
On 09/11/2020 15:36, Georgii Ekserdzhian wrote:
> Good afternoon,
> Can context switch somehow corrupt the static data? Or addressing said data?
> for some reason after the first cpu_context_switch my ready_threads list
> starts acting weird.
>
> Georgii Ekserdzhian
>
More information about the NSWI004
mailing list