int main(int argc, char *argv[])
{
  int n = ARRAY_SIZE;
  int *array;
  HANDLE(!(array = malloc(n * sizeof(int)))); 
  monitor *m;
  
  make_array(&array, n, ARRAY_ALGO, RANGE); 
  NOTIFY(print_array(&array, n, OUT_LINE_SIZE));

  m = monitor_init(SELF);
  monitor_start(m);

  csort(array, n);
  
  monitor_end(m);
 
  NOTIFY(print_array(&array, n, OUT_LINE_SIZE));

  assert(verify(&array, n));


  free(array);
  

  monitor_print_stats(m, VERBOSE);
  monitor_free(m);

  return 0;
}
int main()
{
	int size = SIZE;
	int *first, *result;
	monitor *m;

	first = make_square_matrix(size);
	result = make_square_matrix(size);

	initialize_matrix(first, size);

	NOTIFY(print_matrix(first, size, size));
 
	m = monitor_init(SELF);
	monitor_start(m);

	multiply_matrix_symm_transp(first, result, size);

	monitor_end(m);
	monitor_print_stats(m, VERBOSE);
	
	NOTIFY(print_matrix(result, size, size));
	NOTIFY(verify_matrix(first, result, size));
	
	monitor_free(m);

	return 0;
}
void test_monitor(monitor_target who, bool all_verbosities, bool threaded)
{
	monitor *m = monitor_init(who);

	monitor_start(m);

	if(threaded){
		busy_threads();
	} else {
		busy_loop();
	}

	monitor_end(m);

	if(all_verbosities){
		monitor_print_stats(m, SILENT);
		SMALL_SEP();
		monitor_print_stats(m, QUIET);
		SMALL_SEP();
	}

	monitor_print_stats(m, VERBOSE);
	
	monitor_free(m);
}
Beispiel #4
0
/*
 * Monitor a directory.
 */
int FAMMonitorDirectory(FAMConnection *fc, const char *name, FAMRequest *requestp, void *userdata)
{
    int dir_handle;
    unsigned request, length;
    DirInfo *dir;

#ifdef FAM_DEBUG
    fprintf(stderr, "Asking to monitor directory: %s\n", name);
    fflush(stderr);
#endif

    /* Search for a slot */
    for(request = 0; request != fc->dir_count; request++) {
        if(fc->dirs[request] == 0)
            break;
    }

    /* Watch for overflows */
    if(request == MAX_DIR_COUNT) {
        FAMErrno = FAM_TOO_MANY_DIRECTORIES;
        return -1;
    }
    requestp->reqnum = request;

    /* Get a descriptor for the directory */
    dir_handle = open(name, DIR_OPEN_FLAGS, 0);

    if(dir_handle < 0) {
        /* This is potentially bogus.  It could be any number of things. */
        FAMErrno = FAM_DIRECTORY_DOES_NOT_EXIST;
        return -1;
    }

    /* Allocate a directory struct */
    length = sizeof(DirInfo) + strlen(name);
    dir = (DirInfo *) malloc(length);
    if(dir == 0) {
        close(dir_handle);
        FAMErrno = FAM_OUT_OF_MEMORY;
        return -1;
    }
    memset(dir, 0, length);

    /* Initialize */
    dir->request = request;
    dir->running = 1;
    dir->handle = dir_handle;
    dir->userdata = userdata;
    strcpy(dir->name, name);

    /* Save it in the fc */
    fc->dirs[request] = dir;
    fc->dir_count = MAX(request + 1, fc->dir_count);

    /* Start monitoring */
    monitor_start(fc, dir);
    return 0;
}
Beispiel #5
0
static void monitor_addr_set_cb(proto_t *proto)
{
    int resp;
    if (atoi(proto->list[3]) == 1)
        resp = monitor_start(proto->list[1], atoi(proto->list[2]));
    else
        resp = monitor_stop();

    char buffer[128];
    sprintf(buffer, "resp %i", resp);
    protocol_response(buffer, proto);
}
int main(int argc, char* argv[])
{
	int c, d, swap;
  monitor *m;
  int n = ARRAY_SIZE;
  int *array;

  array = malloc(n * sizeof(int));
  
  make_array(array, n, ARRAY_ALGO); 
  NOTIFY(print_array(array, n, OUT_LINE_SIZE));

  m = monitor_init(SELF);
  monitor_start(m);
  NOTIFY("entering sorting algo\n");

  for (c = 0 ; c < ( n - 1 ); c++)
  {
	  for (d = 0 ; d < n - c - 1; d++)
	  {
		  if (array[d] > array[d+1]) /* For decreasing order use < */
		  {
			  swap       = array[d];
			  array[d]   = array[d+1];
			  array[d+1] = swap;
		  }
	  }
  }
  
  monitor_end(m);
 
  assert(verify(array, n));
  /* print_array(&array, n, OUT_LINE_SIZE); */
  
  monitor_print_stats(m, VERBOSE);

  return 0;
}
int main(int argc, char* argv[])
{
  int n = ARRAY_SIZE;
  int array[ARRAY_SIZE];
  monitor *m;
  
  make_array(&array, n, ARRAY_ALGO); 
  NOTIFY(print_array(&array, n, OUT_LINE_SIZE));

  m = monitor_init(SELF);
  monitor_start(m);

  bsort(&array, n);
  
  monitor_end(m);
 
  assert(verify(&array, n));
  /* print_array(&array, n, OUT_LINE_SIZE); */
  
  monitor_print_stats(m, VERBOSE);

  return 0;
}