[cs33211] Re: Project 1

Mikhail Nesterenko mikhail at cs.kent.edu
Mon Mar 2 23:32:34 EST 2009


> This is my first program for the project. The question I have is whether I
> can use a loop in main to create the 2 threads and pass the arguments from
> argv to the functions?
> 
> If this isn't allowable, how can I pass argv to the other functions? If I
> pass it as a void pointer and try to cast it back into a character array all
> I get is a bunch of strange characters. This is the only way I saw to get
> around the issue of passing argv up to the other 2 functions for the
> threads...

It is preferred that you pass a single integer, that identifiers the
thread. Note that all threads share the process' address space. Thus,
the threads can select the thread-specific data from a shared data
structure.

That is, create a list of strings, pass integers to threads as the
thread identifier and have each thread pick the strings that it needs
from this (shared) list on the basis of its identifier.
--
Mikhail


More information about the cs33211 mailing list