flat assembler
Message board for the users of flat assembler.

Index > Main > I think I'm asking about a spinlock, idk.

Author
Thread Post new topic Reply to topic
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler
I have bunch of functions for my pmm, but I came up with the problem: "What if another thread or process(assuming I ever get to that point) calls and allocates a page already assumed free in another that is paused(there inherently has to be some time between checking if a page is free and marking it used)?"

If tried to make an alloc_lock variable, but some functions that use the lock call other functions that use the lock so it causes the "nested" calls to react as though allocation is locked.

How should this be handled?
Post 20 Jul 2010, 08:34
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
Normally if a thread owns a lock then subsequent calls to lock again succeed and a usage counter is incremented. And the reverse when unlocking.
Post 20 Jul 2010, 11:33
View user's profile Send private message Visit poster's website Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler
How do I tell the difference between a different thread/process calling and a nested call from another page allocating function? I'm assuming I'm going about this the right way. Is there some special way this is supposed to be done? It's my physical mem manager so it has to be system wide, not thread/process specific.

Is it impossible to do this without fully implementing multitasking, with mutexes, spinlocks, etc.? Maybe I should have asked over at OSdev. If anyone sees a cross posting, I'm sorry.
Post 20 Jul 2010, 11:59
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
Tyler wrote:
How do I tell the difference between a different thread/process calling and a nested call from another page allocating function?
You should be able to identify each thread uniquely in some way, an identifier. The lock would normally have a value stored that indicates the current owner, the threads unique identifier is generally used.
Post 20 Jul 2010, 12:14
View user's profile Send private message Visit poster's website Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler
I'm far away from getting anywhere near implementing threads and processes, so I think I may have answered my own question, and you confirmed my answer: "it [is] impossible to do this without [mostly] implementing multitasking"
Post 20 Jul 2010, 12:35
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
If you are not already multi-tasking/multi-threading then you have no need for a lock. Locks are only needed when you have more than one running task.
Post 20 Jul 2010, 12:38
View user's profile Send private message Visit poster's website Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler
I was writing with the future in mind. It just happens that there's no interface for code I haven't written yet. Smile
Post 20 Jul 2010, 12:57
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-2020, Tomasz Grysztar.

Powered by rwasa.