title: C programming - threads, and what is void (*func)(void*, unsigned long)
body: <p>I'm looking at modifying a toy OS system and I'm just trying to learn some of the code and what it does. I have been given a "Thread" structure which has as a member a "pcb" structure, which is a process control block that interfaces the thread to the underlying physical hardware I guess. </p>
  
  <p>Anyways, in this "pcb" structure there's the initialization function which initializes the pcb of a newly created thread. Here's the function definition: </p>
  
  <pre><code>void md_initpcb(struct pcb *, char *stack, void *data1, unsigned long data2,
      void (*func)(void *, unsigned long));
  </code></pre>
  
  <p>With regards to the code, what is the meaning of the last argument? Does it relate to the code or instructions </p>
  
  <p>Conceptually, I'm confused about how stuff fits into the bigger picture. From what I know, a Thread is a unit of execution of code; for example it can relate to user programs, so switching between threads rapidly gives the illusion of running processes in parallel. Alright so this Thread then needs its own stack, registers (don't understand), and some control (the pcb). </p>
  
  <p>Sorry if this is kind of all over the place. For reference, I'm starting the <a href="http://www.eecs.harvard.edu/~syrah/os161/" rel="nofollow">OS161 project</a>. </p>
  
  <p>Thanks.</p>