Thread ID's

octal

New Member
So I'm implementing the Fork system call in the emulated OS Nachos. User threads, of course, are made from the same class as kernel threads. So in implementing Fork I have to assign a unique thread id to newly created threads. Does anyone have any insight into where I should record the id? I figure I should record it in the Thread class, but if I do that then kernel threads will have an id, which I'm pretty sure they aren't supposed to have...
 

Luis G

<i><b>Problemator</b></i>
Staff member
Of the things i recall, fork doesn't make threads, rather it makes son-processes, the difference is that the son process have an instance of its own, while threads share the father's instance.

The micro-kernel i did a while ago didn't have a register track system, i just used the scheduler data structures to keep track of my process.

Since you are emulating you can do pretty much whatever you want, as long as it emulates fine.
 

octal

New Member
Sorry, I should clarify a bit more: the Fork call that we're implementing is a syscall to create a new Thread in the current address space. Normal operating systems would treat a Fork syscall as creating a new process, however the emulated OS we're using is a threaded OS and our job this assignment is to design processes that can Fork to create new Threads, but apparently not new processes (perhaps another assignment). But just placing the ID in the Thread class miiiight work since we aren't required to set the ID for non-process threads (e.g. kernel threads). At this point I'm just wondering if it's bad style to do this.
 

Luis G

<i><b>Problemator</b></i>
Staff member
I really don't know how you are implementing this stuff, you see there are many ways of implementing an OS.

If i was designign it, i'd put a pointer on the PCB (process control block) to a list containing the thread ids. The scheduler should then keep track of the "last" thread that received its quantum in order to keep the time priority on spec with the time assigned to the process on each round.
 
Luis G said:
I really don't know how you are implementing this stuff, you see there are many ways of implementing an OS.

If i was designign it, i'd put a pointer on the PCB (process control block) to a list containing the thread ids. The scheduler should then keep track of the "last" thread that received its quantum in order to keep the time priority on spec with the time assigned to the process on each round.

erm, fuck you too! :confuse3:
 

Luis G

<i><b>Problemator</b></i>
Staff member
I just read the chapter, threads are barely mentioned, sorry i couldn't help further dude.
 

octal

New Member
Thanks for checking! It doesn't need to be done for a few more weeks, so I've got time to keep looking into it.
 
Top