Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!usc!ucsd!ucbvax!hplabs!hp-pcd!hpcvlx!nathanm From: nathanm@hpcvlx.cv.hp.com (Nathan K. Meyers) Newsgroups: comp.os.mach Subject: Re: Wish explanation of some cthread calls Message-ID: <113980003@hpcvlx.cv.hp.com> Date: 27 Nov 89 20:55:37 GMT References: <113980001@hpcvlx.cv.hp.com> Organization: Hewlett-Packard Co., Corvallis, OR, USA Lines: 31 And now that my question has been answered, I'm starting to get the "I'd like to know also" messages. So here's a cc of the clearest explanation I got: > Think of it as ways to store and access data from an arry > indexed by the thread ID. > > Something like > > void* per_thread_data[MAX_THREAD_ID]; > > per_thread_data[thread_id]=x; > /* equiv to cthread_set_data(thread_id,x); > x=per_thread_data[thread_id]; > /* equiv to x=cthread_data(thread_id); > > would achieve the same thing if thread_ids were consecutive. > It's useful in that it is a neat way to get a handle with which > to create your own per-thread data structures. Thanks to Arul A. Menezes for the clear explanation. My big problem in understanding the explanation of these calls in the 1988 Cooper/Draves paper was trying to figure out how these simple semantics allowed you to associate an arbitrary collection of data with a thread. The answer, of course, is that you can associate a single pointer with the thread -- and hang whatever you want off of the pointer. Nathan Meyers nathanm@cv.hp.com