| | |
PThreads: question on basic problem (or POSIX Threads)
![]() |
•
•
Join Date: Oct 2004
Posts: 31
Reputation:
Solved Threads: 0
ok, I have an assignment ...
it requires the use of pthreads ..
i pretty much understand it, well, sorta ....
the assignment is to read input from the command line (input redirection) from a file
the file contains a list of numbers, 1 per line, 50 total numbers max
we are then going to sort the numbers using the Odd-Even Transposition Sorting Algorithm.
so for each number we compare and sort, we are to use pthreads for each set of 2 numbers ...
anyone familiar with the sorting algorithm?
if not, let me know, and ill explain, but otherwise, ill default to the guess that you guys do ...
anyways ....
my question is, with pthreads, you have to create a PThread ID for each pthread call, right?
example:
we declared 2 pthread ID's, "thread1" and "thread2"
this allowed me to create 2 different threads?
but in my assignment, we dont know how many threads we will be creating until we read in all the numbers ....
so im not sure how to declare all the pthread ID's I will need to declare?
any help/point-in-right-direction would be great .....
it requires the use of pthreads ..
i pretty much understand it, well, sorta ....
the assignment is to read input from the command line (input redirection) from a file
the file contains a list of numbers, 1 per line, 50 total numbers max
we are then going to sort the numbers using the Odd-Even Transposition Sorting Algorithm.
so for each number we compare and sort, we are to use pthreads for each set of 2 numbers ...
anyone familiar with the sorting algorithm?
if not, let me know, and ill explain, but otherwise, ill default to the guess that you guys do ...
anyways ....
my question is, with pthreads, you have to create a PThread ID for each pthread call, right?
example:
C Syntax (Toggle Plain Text)
main() { pthread_t thread1, thread2; char *message1 = "Thread 1"; char *message2 = "Thread 2"; int iret1, iret2; /* Create independant threads each of which will execute function */ pthread_create( &thread1, NULL, print_message_function, (void*) message1); pthread_create( &thread2, NULL, print_message_function, (void*) message2); . . . . .
we declared 2 pthread ID's, "thread1" and "thread2"
this allowed me to create 2 different threads?
but in my assignment, we dont know how many threads we will be creating until we read in all the numbers ....
so im not sure how to declare all the pthread ID's I will need to declare?
any help/point-in-right-direction would be great .....
![]() |
Similar Threads
- Problem working with POSIX threads (C)
- Working With Binary Files (C++)
- LCD screen problem or graphics card problem? (Monitors, Displays and Video Cards)
- C++: compile error "subscripted value is neither array nor pointer" (C++)
- problem opening CSV file (C++)
- Visual Studio 2005 & POSIX threads (C)
- Problem on array based list (C)
- Shell Scripting problem and related awk issues (Shell Scripting)
Other Threads in the C Forum
- Previous Thread: C Language
- Next Thread: Array without twice the same number?
| Thread Tools | Search this Thread |
#include adobe ansi api array asterisks binarysearch changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax database directory dynamic execv feet fgets file fork forloop frequency function getlasterror givemetehcodez global grade graphics gtkgcurlcompiling hacking hardware highest histogram i/o include incrementoperators infiniteloop input interest kernel keyboard kilometer license linked linkedlist linux linuxsegmentationfault list locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft motherboard mqqueue mysql number odf opensource owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing scanf segmentationfault sequential shape socket socketprograming standard string systemcall threads turboc unix user voidmain() wab windows.h windowsapi





