Пример #1
0
static void getMutex(int line) {
    ass_printf(150, "%d requesting mutex\n", line);

    pthread_mutex_lock(&mutex);

    ass_printf(150, "%d received mutex\n", line);
}
Пример #2
0
EBBRC
Test::doWork() {
  struct TestPThreadArgs *args;
  int i,j;

  // test iteration loop
  for(j=0; j<iterations; j++){
    args = (struct TestPThreadArgs *)
    malloc(sizeof(struct TestPThreadArgs) * numWorkers);
    tassert((args != NULL), ass_printf("malloc failed\n"));
   for (i=0; i<numWorkers; i++) {
//    TRACE("creating thread #%d\n", i);
      args[i].id = i;
      args[i].index = (j*numWorkers)+i;
      args[i].test = this;
    // create bound threads if specified
    if (bindThread > 0){
      if ( create_bound_thread( &(args[i].tid), i, testPThreadFunc, (void *)&(args[i])) < 0) {
	    perror("pthread_create");
	    exit(-1);
      }
    }else{
      if ( pthread_create( &(args[i].tid), NULL, testPThreadFunc, (void *)&(args[i])) != 0) {
	    perror("create_bound_thread");
	    exit(-1);
      }
    }
  }
    for (i = 0; i<numWorkers; i++)
      pthread_join(args[i].tid, NULL );
      free(args);
  }
  return 0;
}
Пример #3
0
Test::Test(int n, int m, int c, bool p, double wpct) : bar(n), numWorkers(n), iterations(m), numEvents(c), bindThread(p), writePct(wpct)
{
#ifndef __APPLE__
  pthread_barrier_init(&bar2, NULL, n);
#endif
  wargs = (struct Test::WArgs *)
  malloc(sizeof(struct Test::WArgs) * (numWorkers * iterations));
  tassert((wargs != NULL), ass_printf("malloc failed\n"));
}
Пример #4
0
/* release and undisplay all saved regions
 */
void releaseRegions()
{
    region_t* next, *old;
    Writer_t* writer;
    
    if (firstRegion == NULL)
        return;

    writer = getDefaultFramebufferWriter();

    if (writer == NULL)
    {
        ass_err("no framebuffer writer found!\n");
    }

    next = firstRegion;
    while (next != NULL)
    {
        if (writer)
        {
             WriterFBCallData_t out;
                    
             ass_printf(100, "release: w %d h %d x %d y %d\n", 
                                 next->w, next->h, next->x, next->y);

             out.fd            = framebufferFD;
             out.data          = NULL;
             out.Width         = next->w;
             out.Height        = next->h;
             out.x             = next->x;
             out.y             = next->y;

             out.Screen_Width  = screen_width; 
             out.Screen_Height = screen_height; 
             out.destination   = destination;
             out.destStride    = destStride;

             writer->writeData(&out);
             if(threeDMode == 1){
                 out.x = screen_width/2 + next->x;
                 writer->writeData(&out);
             }else if(threeDMode == 2){
                 out.y = screen_height/2 + next->y;
                 writer->writeData(&out);
             }
        }
        old  = next;         
        next = next->next;
        free(old);
    }
    
    firstRegion = NULL;  
}
Пример #5
0
void ass_msg_callback(int level, const char *format, va_list va, void *ctx)
{
    int n;
    char *str;
    va_list dst;

    va_copy(dst, va);
    n = vsnprintf(NULL, 0, format, va);
    if (n > 0 && (str = malloc(n + 1))) {
        vsnprintf(str, n + 1, format, dst);
        ass_printf(100, "%s\n", str);
        free(str);
    }
}
Пример #6
0
/* check for regions which should be undisplayed. 
 * we are very tolerant on time here, because
 * regions are also released when new regions are
 * detected (see ETSI EN 300 743 Chapter Page Composition)
 */
void checkRegions()
{
#define cDeltaTime 2
    region_t* next, *old, *prev;
    Writer_t* writer;
    time_t now = time(NULL);
    
    if (firstRegion == NULL)
        return;

    writer = getDefaultFramebufferWriter();

    if (writer == NULL)
    {
        ass_err("no framebuffer writer found!\n");
    }

    prev = next = firstRegion;
    while (next != NULL)
    {
        if (now > next->undisplay + cDeltaTime)
        {
           ass_printf(100, "undisplay: %ld > %ld\n", now, next->undisplay + cDeltaTime);

           if (writer)
           {
                WriterFBCallData_t out;

                ass_printf(100, "release: w %d h %d x %d y %d\n", 
                                    next->w, next->h, next->x, next->y);

                out.fd            = framebufferFD;
                out.data          = NULL;
                out.Width         = next->w;
                out.Height        = next->h;
                out.x             = next->x;
                out.y             = next->y;
                
                out.Screen_Width  = screen_width; 
                out.Screen_Height = screen_height; 
                out.destination   = destination;
                out.destStride    = destStride;

                writer->writeData(&out);
                if(threeDMode == 1){
                    out.x = screen_width/2 + next->x;
                    writer->writeData(&out);
                }else if(threeDMode == 2){
                    out.y = screen_height/2 + next->y;
                    writer->writeData(&out);
               }
           }
           
           old = next;
           next = prev->next = next->next;

           if (old == firstRegion)
               firstRegion = next;
           free(old);
        } else
        {
            prev = next;
            next = next->next;
        }
    }
}
Пример #7
0
static void releaseMutex(int line) {
    pthread_mutex_unlock(&mutex);

    ass_printf(150, "%d released mutex\n", line);
}