0

hi,
I need help in my work.
Let me give some idea of what I am trying to do.
I have multithreaded C program, where I am suppose to take inputs from different files (a input file for each thread). Threads will execute based on these inputs.
I am struggling in taking multiple inputs and assigning them to separate threads in program.
Can some help me in this.
Please feel free to ask is my problem statement is not clear.
-
ps

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by Ancient Dragon
0

You mean you want to pass argv[1] to thread #1, argv[2] to thread #2 etc. ? Seems pretty trivial to me.

yeah.
ok
dats also fine.
./proggram -redir:file1 -redir:file2 -redir:file3 inputfile1+inputfile2+inputfile3
so here thread1 works on the input from file "inputfile1" and writes output to "file1" and so on.
after I create thread1 how to proceed next.
actually I have not done thread programming before. so I know that its trivial , but still new for me.
please help.

0

At least two ways to accomplish that
1) make a global char* array that is a duplicate of the argv parameter and let each thread access it.

2) pass an argument to the thread when the thread is created. Exactly how to do that depends on how you create the threads.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.