Thread: Calling this function in my main.

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    6

    Calling this function in my main.

    How will I call this function in my main?

    Code:
    void *quickSort( void *ptr)
    {
      struct _qs_data *data = (qs_data *) ptr;
      long left1 = data->left;
      long right1 = data->right;
      long *myArr = data->arr;
      long depth1 = data->depth;
      long result;
      qs_data var1, var2, resVal;
      pthread_t thread1, thread2;
    
      if( left1 < right1 )
        {
          resVal.arr = myArr;
          resVal.left = left1;
          resVal.right = right1;
    
          result = partition(&resVal);
    
          var1.arr = myArr;
          var1.left = left1;
          var1.right = result-1;
          var1.depth = depth1 - 1;
    
          var2.arr = myArr;
          var2.left = result+1;
          var2.right = right1;
          var2.depth = depth1 - 1;
    
          if (depth1 > 0 )
            {
              pthread_create (&thread1, NULL, &quickSort, (void *)&var1);
              pthread_create (&thread2, NULL, &quickSort, (void *)&var2);
    
              pthread_join (thread1, NULL);
              pthread_join (thread2, NULL);
            }
          else
           {
              quickSort ((void *)&var1);
              quickSort ((void *)&var2);
            }
    
          pthread_exit(0);
    
        }
      return (NULL);
    }
    Last edited by filadon; 02-15-2011 at 02:09 PM.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    quicksort( stufftosort );

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > How will I call this function in my main?
    By reading the function, and copying how it calls itself.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    By typing in the correct sequence of characters...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. errors with .h usb rid prog (winuser.h)
    By kryptkat in forum C++ Programming
    Replies: 7
    Last Post: 09-09-2010, 07:44 AM
  2. Replies: 3
    Last Post: 08-16-2010, 10:00 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM