flat assembler
Message board for the users of flat assembler.

Index > OS Construction > threading and stack pointers

Author
Thread Post new topic Reply to topic
jatos



Joined: 04 Nov 2006
Posts: 20
jatos 20 Feb 2007, 16:04
Right... I am currently trying to work how to implement threading and I have come across a problem.

executing a thread, how do I keep a note of where to save the registers in the memory, seeing as the registers will be used by edited by the currently executing program? Are there any registers that is generally accepted are used by the OS and not threads.

_________________
Jamie
Post 20 Feb 2007, 16:04
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 22 Feb 2007, 17:17
Ideally, everything needs to be saved in order for the state in which a thread executes never changes and not have to worry about which registers a thread can and can't use. So each thread needs to have an allocated register store for GPRs including selectors and flags (mov, pushf, popf), FPU (fsave, frstore) and SSE (fxstore, fxrstor) in a lookup table somewhere in memory.

Where you put this table is up to you, just make sure its in ring 0 memory and your OS keeps track of the base address and size of the table, the entries can then be found using the thread's id as an offset.
Post 22 Feb 2007, 17:17
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.