int main() {
    // initialized to four processors
    uthread_init(4);
    
    // semaphores
    mutex = uthread_semaphore_create (1);
    empty = uthread_semaphore_create (0);
    full  = uthread_semaphore_create (MAX_ITEMS);
    
    // create one thread for each producer and one thread for each consumer
    void* arg = (void*) NUM_ITERATIONS;
    uthread_t* producer_thread1 = uthread_create(producer, arg);
    uthread_t* producer_thread2 = uthread_create(producer, arg);
    uthread_t* consumer_thread1 = uthread_create(consumer, arg);
    uthread_t* consumer_thread2 = uthread_create(consumer, arg);
    
    // the main thread must wait for the producer and consumer threads to finish before it exits
    uthread_join(producer_thread1);
    uthread_join(producer_thread2);
    uthread_join(consumer_thread1);
    uthread_join(consumer_thread2);
    
    
    // TESTING AREA
    // the shared resources pool must be 0 when the program terminates, indicating that all produced items were consumed
    printf ("The Pool: %d\n", items);
    int total = 0;
    for (int i = 0; i < MAX_ITEMS+1; i++) {
        total += histogram[i];
        printf ("Histogram: %d\n", histogram[i]);
    }
    printf ("Total changs to items: %d\n", total);
}
Exemplo n.º 2
0
int main (int argc, char** argv) {
  char*                 usage = "usage: reader_writer_test t (0=ns,1=m,2=rwm) count";
  int                   i, type, count;
    
  if (argc==3) {
    type  = atoi (argv[1]);
    count = atoi (argv[2]);
  } else {
    printf ("%s\n", usage);
    exit   (-1);
  }
  
  switch (type) {
    case 0:
      read_proc  = read_ns;
      write_proc = write_ns;
      break;
    case 1:
      read_proc  = read_mon;
      write_proc = write_mon;
      break;
    case 2:
      read_proc  = read_rw_mon;
      write_proc = write_mon;
      break;
    default:
      printf ("%s\n", usage);
      exit   (-1);
  }
  uthread_init (NUM_PROCESSORS);
  do_test (count);
}
Exemplo n.º 3
0
int main (int argc, char** argv) {
    uthread_t t[4];
    
    uthread_init (4);
    
    // TODO: Create Threads and Join
    struct Pool* p = createPool();
    
    for (int i = 0; i < NUM_PRODUCERS; i++) {
        t[i] = uthread_create(producer,p);
    }
    for (int j = NUM_PRODUCERS; j < NUM_PRODUCERS + NUM_CONSUMERS; j++) {
        t[j] = uthread_create(consumer,p);
    }
    for (int z = 0; z < NUM_PRODUCERS + NUM_CONSUMERS; z++) {
        uthread_join(t[z], NULL);
    }
    
    printf ("producer_wait_count=%d, consumer_wait_count=%d\n", producer_wait_count, consumer_wait_count);
    printf ("items value histogram:\n");
    int sum=0;
    for (int i = 0; i <= MAX_ITEMS; i++) {
        printf ("  items=%d, %d times\n", i, histogram [i]);
        sum += histogram [i];
    }
    assert (sum == sizeof (t) / sizeof (uthread_t) * NUM_ITERATIONS);
}
Exemplo n.º 4
0
int
main ()
{
  int i = 0;

  uthread_init ();

  uthread_create (threadFunc, 1, 0);
  uthread_create (threadFunc, 2, 0);
  uthread_create (threadFunc, 3, 0);
  uthread_create (threadFunc, 4, 0);
  //uthread_create (threadFunc, 5, 5);
  //uthread_create (threadFunc, 6, 3);
  //uthread_create (threadFunc, 7, 3);
  //uthread_create (threadFunc, 8, 2);

  // uncomment to test uthread_exit() on main earlier than others
  //uthread_exit();

  while( 1 ) printf("Waiting for interrupt.\n");

  for (i = 0; i < 10; i++)
    {
      printf ("This is the main function\n");
      uthread_yield ();
    }
  printf ("I am main and I am exiting\n");

  uthread_exit ();

  printf ("You shall not reach this line\n");
  return 0;
}
Exemplo n.º 5
0
int main (int argc, char** argv) {
  assert (NUM_PRODUCERS == NUM_CONSUMERS);

  spinlock_create(&item_lock);
  spinlock_create(&producer_wait_count_lock);
  spinlock_create(&consumer_wait_count_lock);

  uthread_init(NUM_PRODUCERS + NUM_CONSUMERS);
  uthread_t producers[NUM_PRODUCERS];
  uthread_t consumers[NUM_CONSUMERS];

  for (int i = 0; i < NUM_PRODUCERS; i++) {
    consumers[i] = uthread_create(consumer, NULL);
    producers[i] = uthread_create(producer, NULL);
  }

  for (int i = 0; i < NUM_PRODUCERS; i++) {
    uthread_join(consumers[i], NULL);
    uthread_join(producers[i], NULL);
  }

  printf("Producer Wait Time: %d\t\tConsumer Wait Time: %d\n",
         producer_wait_count, consumer_wait_count);

  printf("Histogram: [ ");
  int sum = 0;
  for (int i = 0; i < MAX_ITEMS + 1; i++) {
    sum += histogram[i];
    printf("%d ", histogram[i]);
  }
  printf("]\tSum: %d\n", sum);
}
Exemplo n.º 6
0
int main (int argc, char** argv) {
  // TODO create threads to run the producers and consumers
  spinlock_create(&lock);
  uthread_init(4);
  uthread_t producerThread1;
  uthread_t producerThread2;
  uthread_t consumerThread1;
  uthread_t consumerThread2;
  producerThread1 = uthread_create(producer, 0);
  producerThread2 = uthread_create(producer, 0);
  consumerThread1 = uthread_create(consumer, 0);
  consumerThread2 = uthread_create(consumer, 0);
  uthread_join(producerThread1, 0);
  uthread_join(producerThread2, 0);
  uthread_join(consumerThread1, 0);
  uthread_join(consumerThread2, 0);
  printf("Producer wait: %d\nConsumer wait: %d\n",
         producer_wait_count, consumer_wait_count);
  for(int i=0;i<MAX_ITEMS+1;i++)
    printf("items %d count %d\n", i, histogram[i]);
/*   uthread_join(producerThread1, 0);
  uthread_join(producerThread2, 0);
  uthread_join(consumerThread1, 0);
  uthread_join(consumerThread2, 0); */
}
Exemplo n.º 7
0
int
main(int ac, char **av)
{
    int	i;

    uthread_init();
    
    uthread_mtx_init(&mtx1);
    uthread_mtx_init(&mtx2);
    uthread_mtx_init(&mtx3);

    uthread_cond_init(&cond);
    
    void (*tester[3]) (long a0, void* a1);
    tester[0] = tester1;
    tester[1] = tester2;
    tester[2] = tester3;

    for (i = 0; i < NUM_THREADS; i++)
    {
        
        uthread_create(&thr[i], tester[i], i, NULL,  UTH_MAXPRIO - i % UTH_MAXPRIO
                                        //2
                                        );
    }

    //uthread_setprio(thr[0], 6);

    for (i = 0; i < NUM_THREADS; i++)
    {
        char pbuffer[SBUFSZ];
        int	tmp, ret;

        uthread_join(thr[i], &tmp);
    
        sprintf(pbuffer, "joined with thread %i, exited %i.\n", thr[i], tmp);  
        ret = write(STDOUT_FILENO, pbuffer, strlen(pbuffer));
        if (ret < 0) 
        {
            perror("uthreads_test");
            return EXIT_FAILURE;
        }   

        /* 
        uthread_mtx_lock(&mtx);
        uthread_cond_signal(&cond);
        uthread_mtx_unlock(&mtx);
        */
        
    }
    printf("Main ends\n");
    uthread_exit(0);

    return 0;

}
Exemplo n.º 8
0
int main (int* argc, char** argv) {
  uthread_t *ping_thread, *pong_thread;
  int i;
  uthread_init (2);
  ping_thread = uthread_create (ping, 0);
  pong_thread = uthread_create (pong, 0);
  uthread_join (ping_thread);
  uthread_join (pong_thread);
  printf ("\n");
}
Exemplo n.º 9
0
int main(int argc, char **argv) {
  printf("Testing uthread_create\n");
	    
  uthread_init();
    
  uthread_create(thread_start, 1, 0); 
      
  uthread_yield();
  printf("back in main\n");
  uthread_exit();
  return 0;
}
Exemplo n.º 10
0
int main (int argc, char** argv) {
  uthread_init (7);
  struct Agent*  a = createAgent();
  // TODO
  uthread_join (uthread_create (agent, a), 0);
  assert (signal_count [MATCH]   == smoke_count [MATCH]);
  assert (signal_count [PAPER]   == smoke_count [PAPER]);
  assert (signal_count [TOBACCO] == smoke_count [TOBACCO]);
  assert (smoke_count [MATCH] + smoke_count [PAPER] + smoke_count [TOBACCO] == NUM_ITERATIONS);
  printf ("Smoke counts: %d matches, %d paper, %d tobacco\n",
          smoke_count [MATCH], smoke_count [PAPER], smoke_count [TOBACCO]);
}
Exemplo n.º 11
0
Arquivo: fssp.c Projeto: bitc/2
int
main(int argc, char *argv[])
{
  int i;

  if(argc != 2) {
    printf(2, "You must pass the number of soldiers\n");
    exit();
  }

  n = atoi(argv[1]);

  if(n < 1) {
    printf(2, "Number of soldiers must be positive\n");
    exit();
  }

  uthread_init();

  for(i = 0; i < n; ++i) {
    binary_semaphore_init(&soldier_ready[i], 0);
    binary_semaphore_init(&soldier_waiting[i], 0);
    binary_semaphore_init(&soldier_prepared[i], 0);
    binary_semaphore_init(&soldier_update[i], 0);
  }

  for(i = 0; i < n; ++i) {
    uthread_create(run_soldier, (void*)i);
  }

  for(;;) {
    for(i = 0; i < n; ++i) {
      binary_semaphore_down(&soldier_ready[i]);
    }

    print_cells();
    if(all_firing()) {
      exit();
    }

    for(i = 0; i < n; ++i) {
      binary_semaphore_up(&soldier_waiting[i]);
    }

    for(i = 0; i < n; ++i) {
      binary_semaphore_down(&soldier_prepared[i]);
    }

    for(i = 0; i < n; ++i) {
      binary_semaphore_up(&soldier_update[i]);
    }
  }
}
Exemplo n.º 12
0
int
main(int argc, char *argv[])
{
uthread_init();
int stam = 10;
int stam1 = 12;
int stam2 = 20;
uthread_create(tester,&stam);
uthread_create(tester,&stam1);
uthread_create(tester,&stam2);
uthread_exit();
return 0;
}
Exemplo n.º 13
0
int
main(int ac, char **av)
{
    int	i;


/*
    char buff[50];
    memset(buff,0,50);
    sprintf(buff, "helloworld\n");
    write(STDOUT_FILENO, buff, strlen(buff));
*/
    printf("hello\n");

    uthread_init();
    uthread_mtx_init(&mtx);
    uthread_cond_init(&cond);

    for (i = 0; i < NUM_THREADS; i++)
    {
        uthread_create(&thr[i], tester, i, NULL, 0);
    }
    uthread_setprio(thr[0], 2);


    for (i = 0; i < NUM_THREADS; i++)
    {
        char pbuffer[SBUFSZ];
        int	tmp, ret;

        uthread_join(thr[i], &tmp);
    
        sprintf(pbuffer, "joined with thread %i, exited %i.\n", thr[i], tmp);  
        ret = write(STDOUT_FILENO, pbuffer, strlen(pbuffer));
        if (ret < 0) 
        {
            perror("uthreads_test");
            return EXIT_FAILURE;
        }   

        uthread_mtx_lock(&mtx);
        uthread_cond_signal(&cond);
        uthread_mtx_unlock(&mtx);
    }

    uthread_exit(0);

    return 0;
}
Exemplo n.º 14
0
//-----------------------------------PART 3
int main(){
   uthread_init();
   
   
    struct binary_semaphore semaphore;
    binary_semaphore_init(&semaphore, 1); 
    

    uthread_create(&foo, &semaphore);
    uthread_create(&foo, &semaphore);
//     uthread_join(2);
    
    uthread_exit();
    
    exit();
}
Exemplo n.º 15
0
int main (int argc, char** argv) {
  static const char* usage = "usage: sRead numBlocks";
  int numBlocks = 0;
  
  if (argc == 2)
    numBlocks = strtol (argv [1], NULL, 10);
  if (argc != 2 || (numBlocks == 0 && errno == EINVAL)) {
    printf ("%s\n", usage);
    return EXIT_FAILURE;
  }
  
  uthread_init (1);
  disk_start   (interruptServiceRoutine);
  
  run (numBlocks);
}
Exemplo n.º 16
0
int main (int argc, char** argv) {
  // setup mutex and condition variables
  mx = uthread_mutex_create();
  smoker_waiting = uthread_cond_create(mx);
  for (int i = 0; i < 3; i++) {
    resource[i] = uthread_cond_create(mx);
  }
  done_smoking = uthread_cond_create(mx);

  // setup threads and start agent
  uthread_init(1);
  uthread_mutex_lock(mx);
  for (int i = 0; i < 3; i++) {
    threads[i] = uthread_create(smoker, (void*)(intptr_t) i);
    uthread_cond_wait(smoker_waiting);
  }
  uthread_mutex_unlock(mx);
  threads[3] = uthread_create(agent, NULL);

  // wait for threads to finish
  for (int i = 3; i >= 0; i--) {
    uthread_join(threads[i], NULL);
  }

  // verify that the histograms of actual/expected match
  for (int i = 0; i < 3; i++) {
    assert(histo_expected[i] == histo_actual[i]);
  }

  // print histograms of expected and actual smoke counts
  int sum;
  printf("Expected: [ ");
  sum = 0;
  for (int i = 0; i < 3; i++) {
    sum += histo_expected[i];
    printf("%d ", histo_expected[i]);
  }
  printf("]\tSum: %d\n", sum);

  sum = 0;
  printf("Actual:   [ ");
  for (int i = 0; i < 3; i++) {
    sum += histo_actual[i];
    printf("%d ", histo_actual[i]);
  }
  printf("]\tSum: %d\n", sum);
}
Exemplo n.º 17
0
int main(int argc, char* argv[])
{
	if(argc < 2)
        {
		printf("Please enter a positive integer as argument.\n");
		return 0;
	}

        int n = atoi(argv[1]);

        if(n < 0)
        {
		printf("Negative argument. Please enter a positive integer as argument.\n");
		return 0;
	}

	uthread_init();
	id1 = uthread_create(proc1, &n);

	if(id1 != -1)
	{
		printf("--Created thread 1--\n");
	}
	else
	{
		printf("--Creation of thread 1 failed--\n");
	}

	id2 = uthread_create(proc2, &n);

	if(id2 != -1)
	{
		printf("--Created thread 2--\n");
	}
	else
	{
		printf("--Creation of thread 2 failed--\n");
	}

	uthread_join(id1);
	uthread_join(id2);

	printf("--End of main--\n");

	return 0;
}
Exemplo n.º 18
0
/* Main: Compute ((1 + 2) - (3 + 4)) + 7 with threads. */
int 
main ( int* argc, char** argv ) 
{
		uthread_init( 2 );

		/* Create structs for (1 + 2) and (3 + 4). */
		struct Triple *t1 = (struct Triple*) malloc( sizeof( struct Triple ) );
		t1->arg0 = 1;
		t1->arg1 = 2;
		struct Triple *t2 = (struct Triple*) malloc( sizeof( struct Triple ) );
		t2->arg0 = 3;
		t2->arg1 = 4;

		/* Create threads for (1 + 2) and (3 + 4). */
		uthread_t *t1_thread, *t2_thread;
		t1_thread = uthread_create( add, (void*) t1 );
		t2_thread = uthread_create( add, (void*) t2 );

		/* Execute (1 + 2) and (3 + 4) and store results. */
		int r1 = *( (int *) uthread_join( t1_thread ) );
		int r2 = *( (int *) uthread_join( t2_thread ) );

		/* Create struct for (r1 - r2). */
		struct Triple *t3 = (struct Triple*) malloc( sizeof( struct Triple ) );
		t3->arg0 = r1;
		t3->arg1 = r2;

		/* Create thread for (r1 - r2). */
		uthread_t *t3_thread = uthread_create ( sub, (void *) t3 );
		int r3 = *( (int *) uthread_join( t3_thread ) );

		/* Create struct for (r3 + 7). */
		struct Triple *t4 = (struct Triple*) malloc( sizeof( struct Triple ) );
		t4->arg0 = r3;
		t4->arg1 = 7;

		/* Create thread for (r3 + 7). */
		uthread_t *t4_thread = uthread_create ( add, (void *) t4 );
		int r4 = *( (int *) uthread_join( t4_thread ) );
		
		printf( "%d\n", r4 );
}
Exemplo n.º 19
0
int
main(int ac, char **av)
{
    thread_t td;
    thread_t td1;
    thread_t td2;

    uthread_init();
    td = curthread;
    printf("mainthread %p crit_count %d nest %d mp_lock %d\n", 
	td, td->td_pri / TDPRI_CRIT, td->td_mpcount, mp_lock
    );
    lwkt_create(thread1, NULL, &td1, NULL, 0, -1, "thread1");
    lwkt_create(thread2, NULL, &td2, NULL, 0, -1, "thread2");
    printf("thread #1 %p #2 %p\n", td1, td2);
    printf("switching away from main (should come back before exit)\n");
    lwkt_switch();
    printf("Switched back to main, main Exiting\n");
    exit(1);
}
Exemplo n.º 20
0
int main (int argc, char** argv) {
  uthread_init (1);
  struct Washroom* washroom = createWashroom();
  uthread_t        pt [NUM_PEOPLE];
  waitingHistogrammutex = uthread_mutex_create ();

  // TODO
  
  printf ("Times with 1 male    %d\n", occupancyHistogram [MALE]   [1]);
  printf ("Times with 2 males   %d\n", occupancyHistogram [MALE]   [2]);
  printf ("Times with 3 males   %d\n", occupancyHistogram [MALE]   [3]);
  printf ("Times with 1 female  %d\n", occupancyHistogram [FEMALE] [1]);
  printf ("Times with 2 females %d\n", occupancyHistogram [FEMALE] [2]);
  printf ("Times with 3 females %d\n", occupancyHistogram [FEMALE] [3]);
  printf ("Waiting Histogram\n");
  for (int i=0; i<WAITING_HISTOGRAM_SIZE; i++)
    if (waitingHistogram [i])
      printf ("  Number of times people waited for %d %s to enter: %d\n", i, i==1?"person":"people", waitingHistogram [i]);
  if (waitingHistogramOverflow)
    printf ("  Number of times people waited more than %d entries: %d\n", WAITING_HISTOGRAM_SIZE, waitingHistogramOverflow);
}
Exemplo n.º 21
0
thread_id uthread_create(UTHREAD_START_ROUTINE start_routine,void* arg) {
    thread_t *thread;

    if(threads == 0) {
	if(uthread_init() == UTHREAD_FAIL)
	    return UTHREAD_FAIL;
    }
    uthread_disable();
    thread = uthread_alloc(start_routine,arg);
    
    /* We save this point as new thread execution start. When we return here,
     * we spawn the thread and start it's execution. */
    /* JMP_BUF_SP(thread->stack) = ((long)uthread_stack_alloc())+UTHREAD_DEF_STACK_SIZE; */
    if(sigsetjmp(thread->stack,1)) {
	/* Execute this if we returned with siglongjmp. This will happen when
	 * jumping from alarm handler. */
	uthread_spawn(current);
    }
    JMP_BUF_SP(thread->stack) = ((long)uthread_stack_alloc())+UTHREAD_DEF_STACK_SIZE;
    uthread_enable();
    return thread->id;
}
int main(int argc, char* argv[])
{
	if(argc < 2)
        {
		printf("Please enter a positive integer as argument.\n");
		return 0;
	}

        int n = atoi(argv[1]);

        if(n < 0)
        {
		printf("Negative argument. Please enter a positive integer as argument.\n");
		return 0;
	}

	int id;

	uthread_init();
	id = uthread_create(parent, &n);

	if(id != -1)
	{
		printf("--Created parent thread--\n");
	}
	else
	{
		printf("--Creation of parent thread failed--\n");
	}

	uthread_join(id);

	printf("--End of parent thread--\n");

	uthread_wait();

	return 0;
}
Exemplo n.º 23
0
int main (int argc, char** argv) {
  assert (NUM_PRODUCERS == NUM_CONSUMERS);

  mx = uthread_mutex_create();
  not_empty = uthread_cond_create(mx);
  not_full = uthread_cond_create(mx);

  uthread_init(NUM_PRODUCERS + NUM_CONSUMERS);
  uthread_t producers[NUM_PRODUCERS];
  uthread_t consumers[NUM_CONSUMERS];

  for (int i = 0; i < NUM_PRODUCERS; i++) {
    consumers[i] = uthread_create(consumer, NULL);
    producers[i] = uthread_create(producer, NULL);

  }

  for (int i = 0; i < NUM_PRODUCERS; i++) {
    uthread_join(consumers[i], NULL);
    uthread_join(producers[i], NULL);
  }

  uthread_cond_destroy(not_full);
  uthread_cond_destroy(not_empty);
  uthread_mutex_destroy(mx);

  printf("Producer Wait Time: %d\tConsumer Wait Time: %d\n",
         producer_wait_count, consumer_wait_count);

  printf("Histogram: [ ");
  int sum = 0;
  for (int i = 0; i < MAX_ITEMS + 1; i++) {
    sum += histogram[i];
    printf("%d ", histogram[i]);
  }
  printf("]\tSum: %d\n", sum);
}
Exemplo n.º 24
0
int rms_init(void) {
	int ret;
	struct hostent *hp;

	rmsb->version = 0;
	mqueue_init( &(rmsb->mq_channels), 3);
	syncqueue_init( &(rmsb->mq_channels_tmp), 3);
	syncqueue_init( &(rmsb->mq_meta_msg_pool), 10);

	uthread_mutex_init(&mutx_rmscb);

	rmsb->state = 0;

	rmsb->hostname = (char*)malloc(64);

	if(gethostname(rmsb->hostname, 64) < 0)
		return -1;

	hp = gethostbyname(rmsb->hostname);
	rmsb->id = ((struct in_addr*)hp->h_addr)->s_addr;

	memcpy(rmsb->ip_addr,hp->h_addr, sizeof(ip_addr));

	rms_peer_init(&rmsb->self, rmsb->hostname, rmsb->id);
	rmsb->initialized = RMS_INITIALIZED;

	rmsb->maxsock = 0;
	rmsb->n_channels = 0;

	rmsb->sock = 0;
	rmsb->listening = 0;
	rmsb->error = 0;
	rmsb->active = 1;

	//init threads
	if(uthread_init(& (rmsb->rms_mgr_thr), rms_manager, 1) < 0) {
		rmsb->error = RMS_ERR_THREADING;
		return -1;
	}
	if(uthread_init(& (rmsb->rms_snd_thr), rms_sender, 1) < 0) {
		rmsb->error = RMS_ERR_THREADING;
		return -1;
	}
	if(uthread_init(& (rmsb->rms_rcv_thr), rms_receiver, 1) < 0) {
		rmsb->error = RMS_ERR_THREADING;
		return -1;
	}

	//start threads
	if(uthread_start(&(rmsb->rms_mgr_thr), rmsb) < 0) {
		rmsb->error = RMS_ERR_THREADING;
		return -1;
	}
	if(uthread_start(&(rmsb->rms_snd_thr), rmsb) < 0) {
		rmsb->error = RMS_ERR_THREADING;
		return -1;
	}
	if(uthread_start(&(rmsb->rms_rcv_thr), rmsb) < 0) {
		rmsb->error = RMS_ERR_THREADING;
		return -1;
	}
	return 0;
}
Exemplo n.º 25
0
int main(int argc,char** argv)
{
	int i;
	if(argc!=2)
	{
		printf(1,"please write how much soldiers do you want (LESS THEN 64)\n");
		goto out_err;
	}

	soldiersAmount=atoi(argv[1]);

	if(soldiersAmount>64 || soldiersAmount<2)
	{
		printf(1,"please write how much soldiers do you want (LESS THEN 64)\n");
		goto out_err;
	}

	currentState[0][0]=AS;
	currentState[1][0]=AS;
	currentState[0][soldiersAmount+1]=AS;
	currentState[1][soldiersAmount+1]=AS;

	state=0;
	counter=0;
	binary_semaphore_init(&arrival,1);
	binary_semaphore_init(&departure,0);
	binary_semaphore_init(&printing,0);

	fatherPID=getpid();
	signal(4,printArray);

	currentState[0][1]=P;
	for(i=2; i<=soldiersAmount;i++)
	{
		currentState[0][i]=Q;
	}
	uthread_init();


	int tid;
	for(i=1;i<=soldiersAmount;i++)
	{
		tid = uthread_create(run, (void *) i);
		if (!tid)
			goto out_err;
	}


	while (currentState[0][i]!=F && currentState[1][i]!=F)
	{
		binary_semaphore_down(&printing);
		printArray();
	}


	printArray();
	printArray();
	uthread_exit();

	out_err:
	printf(1,"Faild to create thread, we go bye bye\n");
	exit();
}