I am working on a producer/consumer problem and need a little help on calling my functions in a posix thread. What would be the correct syntax for calling producer?
Nothing seems to be working for me today. I have had to delete all my curly braces from from my code in order for it to let me post. When I left them in it kept telling me to use code tags, which I was already using.
An explanation of parts of the thread call might helpCode:#include <iostream> #include <fstream> #include <cstdlib> #include <cctype> #include <string> #include <pthread.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> using namespace std; #define N 100 typedef int semaphore; semaphore mutex =1; semaphore empty = N; semaphore full = 0; bool TRUE = TRUE; pthread_t thread1, thread2, thread3, thread4; int err1, err2, err3, err4; void producer(); int remove_item(); void consumer(); int produce_item(); void insert_item (int item); semaphore down (semaphore value); int up (int &value); void consume_item(int item); int main(int argc, char* argv) // err1 = pthread_create(&thread1, NULL, producer() (void*));//trying to call producer here // void producer() // cout<<("producer stuff")<<endl; int item; while (TRUE) // item = produce_item(); down(empty); down(mutex); insert_item(item); up(mutex); up(full); // //
I.E
pthread_create(&thread1, NULL, producer() (void*));
1st slot:
&thread = the pthread you want to use?
2nd slot:
NULL= something?
3rd slot:
Produce() = the fuction i am trying to call?
4th slot:
(void*) = some crazy C thing?



LinkBack URL
About LinkBacks


