#include <rtl_conf.h>
#include <time.h>
#include <pthread.h>
#include <rtl_ipc.h>
#include <semaphore.h>
#include <rtl_barrier.h>
#include <unistd.h>
#include "examples.h"

#if BARRIERS_EXAMPLE 


static unsigned long valor3=0x0;
static unsigned long valor4=0x0;


pthread_t thread3;
pthread_t thread4;

#if CONFIG_OC_PBARRIERS 
pthread_barrier_t   barrier; // barrier synchronization object
pthread_barrierattr_t barrier_attr;
#endif

void *task3(void *arg)
{
#if CONFIG_OC_PBARRIERS 
  while(1)
  {
    pthread_barrier_wait (&barrier);
//    hexatoascii(valor3,(char *) 0xb8000+80*6+10);
    valor3++;
    //Sleep 3 seconds
    usleep(3000000);
  };
#else
  while(1) {};
#endif
  return 0;
};


void *task4(void *arg)
{
#if CONFIG_OC_PBARRIERS 
  while(1)
  {
    pthread_barrier_wait (&barrier);
//    hexatoascii(valor4,(char *) 0xb8000+80*6+20);
    valor4++;
  };
#else
  while(1) {};
#endif
  
  return 0;
};





#endif
