flat assembler
Message board for the users of flat assembler.

Index > OS Construction > good method of deciding process ID

Author
Thread Post new topic Reply to topic
david



Joined: 16 Jun 2003
Posts: 5
david
Would reading the timestamp counter be a good method of creating a process ID for a process or thread?

or does it suck? Timestamp counter will reset (overflow?, dont know the correct english word... ) after whatever time since of the limitations of bits, I know, and it might produce the same result if unlucky.

Maybe time-stamp in conjunction of something else?

thanks! / david
Post 07 Apr 2004, 23:49
View user's profile Send private message ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Why not the index value into the system process table?
Post 08 Apr 2004, 11:45
View user's profile Send private message Visit poster's website Reply with quote
david



Joined: 16 Jun 2003
Posts: 5
david
Hi fodder!

Yes why not.. it seems simple and good.
I could keep a counter that increments by one for each created thread/process, and use that as processID and hash into a hash-table with pointers to process structures.
Eventually, after 0xFFFFFFFF created threads the counter will reset, but I don't think there's any risk my hobby-kernel will ever run that long Very Happy

(maybe if picky I could use a 64bit counter, but that seems overkill for now.. or perhaps 64bit pid where the top DWORD is the low 32bits returned from RDTSC when process was created, and the bottom DWORD is the value of the incrementing counter ~ that should be foolproof also I think)
Post 09 Apr 2004, 16:27
View user's profile Send private message ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
On overflow you could always wrap around and re-use old values - it's not very likely that you get 2^32 processes, and even less likely that they would all keep running Razz

There are some things to consider, though... like "namespaces", should thread handles (for instance) be unique on the entire system, or only in a single process? What will you do for fast handle lookups (direct index values aren't all that good if you want to support a whole bunch of processes and threads, and searching a linked list linearly could also turn out to be slow).
Post 09 Apr 2004, 21:36
View user's profile Send private message Visit poster's website Reply with quote
david



Joined: 16 Jun 2003
Posts: 5
david
Quote:

On overflow you could always wrap around and re-use old values - it's not very likely that you get 2^32 processes, and even less likely that they would all keep running Razz


Right!

Quote:

There are some things to consider, though... like "namespaces", should thread handles (for instance) be unique on the entire system, or only in a single process? What will you do for fast handle lookups (direct index values aren't all that good if you want to support a whole bunch of processes and threads, and searching a linked list linearly could also turn out to be slow).


Mind-boggling! Namespaces, didn't even think of something like that yet, and neither do I know what this mean in the case of processes.
Like, why would I wanna keep some processes only unique to a certain process, and not to the whole system?
Please elaborate some more on that if you wanna, or put some link, I would appreciate it! Smile

But for fast handle lookups I wanna use a hash-table like I told previously, it is very fast. I would never use a linked list for that.

I'm not by far doing theese kinda things yet, I'm still working with creating a priority scheduler for kernel threads that is working ok, but its still good to kinda plan ahead!

thanks and have a good day Smile
Post 10 Apr 2004, 02:49
View user's profile Send private message ICQ Number 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-2019, Tomasz Grysztar.

Powered by rwasa.