void
thread_func(void *a)
{
  desch(&guard); // sleeps here because guard is always non-zero

  TEST_FAIL_IF(!has_mkran[(int) a], "came out of desch before mkrun");
  TEST_FINI("iteration %d", (int) a);
  texit();
}
예제 #2
0
tmain()
{
#if _lib_locale
	char		buf[128], cmp[128];
	float		d;
	int		n, decimal, thousand;
	struct lconv*	lv;

	setlocale(LC_ALL, "");

	if(!(lv = localeconv()))
		texit(0);

	decimal = '.';
	if(lv->decimal_point && lv->decimal_point[0])
		decimal = lv->decimal_point[0];

	thousand = 0;
	if(lv->thousands_sep && lv->thousands_sep[0])
		thousand = lv->thousands_sep[0];
		
	if(thousand)
		sfsprintf(cmp, sizeof(cmp), "1%c000", thousand);
	else	sfsprintf(cmp, sizeof(cmp), "1000");
	sfsprintf(buf, sizeof(buf), "%'d", 1000);
	if(strcmp(buf, cmp) != 0)
		terror("Bad printing");
	
	if(thousand)
		sfsprintf(cmp, sizeof(cmp), "1%c000%c10", thousand, decimal);
	else	sfsprintf(cmp, sizeof(cmp), "1000%c10", decimal);
	d = 0.;
	if((n = sfsscanf(cmp, "%'f", &d)) != 1)
		terror("Scan error %d", n);
	if(d < 1000.099 || d > 1000.101)
		terror("Bad scanning");
	sfsprintf(buf, sizeof(buf), "%.2f", d);
	if(strcmp(buf, "1000.10") != 0)
		terror("Deep formatting error");
#endif

	texit(0);
}
예제 #3
0
파일: testproc.c 프로젝트: liuhuac/OS
/* sub1: Test child thread */
void sub1() {
  int i, delay;;
  for (i=0; i<20; i++) {
   printf("Hello from sub 1, loop %d\n", i);
   for (delay=0; delay<50000; delay++) /* Do nothing delay loop */;
   tyield();
  }
  printf(">>>sub 1 ending\n");
  texit();
}
예제 #4
0
void oReady(void *arg_ptr) {
	sem_acquire(&h);
	sem_acquire(&h);
	sem_signal(&o);
	sem_signal(&o);
	lock_acquire(&mutex);
	water_molecules++;
	lock_release(&mutex);
	texit();
}
예제 #5
0
파일: tungetc.c 프로젝트: att/ast
tmain() {
    UNUSED(argc);
    UNUSED(argv);
    Sfio_t *f;
    char *str, *alpha, *s;
    char buf[128];
    int n;

    str = "0123456789";
    alpha = "abcdefghijklmnop";

    if (!(f = sfopen(NULL, alpha, "s"))) terror("Opening stream");

    for (n = 9; n >= 0; --n) {
        if (sfungetc(f, n + '0') != n + '0') terror("Ungetc");
    }

    if (!(s = sfreserve(f, SF_UNBOUND, 0)) || sfvalue(f) != 10) terror("Peek stream1");
    if (strncmp(s, str, 10) != 0) terror("Bad data1");

    if (!(s = sfreserve(f, SF_UNBOUND, 0)) || sfvalue(f) != (ssize_t)strlen(alpha)) {
        terror("Peek stream2");
    }
    if (strncmp(s, alpha, strlen(alpha)) != 0) terror("Bad data2");

    sfseek(f, (Sfoff_t)0, 0);
    for (n = 9; n >= 0; --n) {
        if (sfungetc(f, n + '0') != n + '0') terror("Ungetc2");
    }
    if (sfgetc(f) != '0') terror("Sfgetc");
    sfseek(f, (Sfoff_t)0, 0);
    if (!(s = sfreserve(f, SF_UNBOUND, 0)) || sfvalue(f) != (ssize_t)strlen(alpha)) {
        terror("Peek stream3");
    }
    if (strncmp(s, alpha, strlen(alpha)) != 0) terror("Bad data2");

    sfseek(f, (Sfoff_t)0, 0);
    if (sfungetc(f, '0') != '0') terror("Ungetc3");

    strcpy(buf, "0123456789\n");
    if (!(f = sfopen(f, buf, "s+"))) terror("Reopening  string");
    if (sfungetc(f, '\n') != '\n') terror("Can't unget new-line2");
    if (sfungetc(f, 'd') != 'd') terror("Can't unget d");
    if (sfungetc(f, 'c') != 'c') terror("Can't unget c");
    if (sfungetc(f, '\n') != '\n') terror("Can't unget new-line");
    if (sfungetc(f, 'b') != 'b') terror("Can't unget b");
    if (sfungetc(f, 'a') != 'a') terror("Can't unget a");

    if (!(s = sfgetr(f, '\n', 1)) || strcmp(s, "ab") != 0) terror("Did not get ab");
    if (!(s = sfgetr(f, '\n', 1)) || strcmp(s, "cd") != 0) terror("Did not get cd");
    if (!(s = sfgetr(f, '\n', 1)) || strcmp(s, "0123456789") != 0) terror("Did not get 0123456789");

    texit(0);
}
예제 #6
0
void CannibalArrives()
{
	sem_aquire(&boat);
	
	sem_aquire(&display);
	printf(1, "1: (%d) cannibal arrived, %d, %d\n", getpid(), total, con);
	sem_signal(&display);	


	sem_aquire(&mutex2);
	while(total + 2 == 5) { con++;
	sem_signal(&mutex2);
	sem_signal(&boat);
	
	sem_aquire(&display);
	printf(1, "1: (%d) cannibal denied boarding, %d, %d\n", getpid(), total, con);
	sem_signal(&display);

	sem_aquire(&prevention);

	sem_aquire(&display);
	printf(1, "1: (%d) cannibal prevented meal, %d, %d\n", getpid(), total, con);
	sem_signal(&display);

	
	sem_aquire(&boat);
	sem_aquire(&mutex2);
	}
	sem_signal(&mutex2);
	sem_aquire(&mutex2);
	total += 2;
	sem_signal(&mutex2);
	
	sem_aquire(&display);
	printf(1, "2: (%d) cannibal enters boat, %d, %d\n", getpid(), total, con);
	sem_signal(&display);	
	
	sem_aquire(&mutex);
	bp++;
	sem_signal(&mutex);
	if (bp < 3)	sem_aquire(&loading);
	
	
	
	// sem_aquire(&display);
	// printf(1, "bp cannibal: %d\n", bp);
	// sem_signal(&display);
	
	RowBoat();
	sem_signal(&loading);

	
	texit();
}
예제 #7
0
Value *primitiveLess(Value *args){
    //Creates a bool type that is default true. It then creates a double type called check and that is the first value being compared to.

    if (length(args) != 2){
        printf("Evaluation Error: the number of arguments is not 2\n");
        texit(1);
    }
    Value *result = talloc(sizeof(Value));
    result->type = BOOL_TYPE;
    result->i = 1;
    double check;
    if (length(args) != 2) {
        printf("Evaluation Error: not a correct number of arguments\n");
        texit(1);
    }
    if (car(args)->type == INT_TYPE) {
        check = car(args)->i;
    } else if (car(args)->type == DOUBLE_TYPE) {
        check = car(args)->d;
    } else {
        printf("Evaluation Error: argument not a number\n");
        texit(1);
    }
    args = cdr(args);
    //This then compares check to the second value. If check is greater than or equal to the second val, change bool type to false and return, otherwise return the default true.
    if (car(args)->type == INT_TYPE) {
        if (check >= car(args)->i) {
            result->i = 0;
            return result; 
        }
    } else if (car(args)->type == DOUBLE_TYPE) {
        if (check >= car(args)->d) {
            result->i = 0;
            return result;
        }
    } else {
        printf("Evaluation Error: argument not a number\n");
        texit(1);
    }
    return result;
}
예제 #8
0
tmain()
{
	Dt_t*	dt;
	Obj_t	*o, proto;
	long	i, k, count, n;

	for(i = 0; i < N_OBJ; i = k)
	{	for(k = i; k < i+R_OBJ && k < N_OBJ; ++k)
		{	Obj[k].key = i;
			Obj[k].ord = k;
		}
	}

	for(k = 0; k < 2; ++k)
	{	if(!(dt = dtopen(&Disc, k == 0 ? Dtrhbag : Dtobag)) )
			terror("Opening dictionary");
		dtcustomize(dt, DT_SHARE, 1); /* turn on sharing */

		for(i = 0; i < N_OBJ; ++i)
		{	if(dtinsert(dt, Obj+i) != Obj+i)
				terror("Insert %d,%d", Obj[i].key, Obj[i].ord);

			if(i > 0 && (i%N_CHK) == 0)
				if((count = dtsize(dt)) != i+1)
					terror("Bad size %d (need %d)", count, i+1);
		}

		count = n = 0; /* count the group of elements with key == 0 */
		for(o = (Obj_t*)dtflatten(dt); o; o = (Obj_t*)dtlink(dt,o), count += 1)
			if(o->key == 0)
				n += 1;
		if(count != N_OBJ || n != R_OBJ)
			terror("flatten %s: count=%d(need=%d) n=%d(need=%d)",
				k == 0 ? "bag" : "obag", count, N_OBJ, n, R_OBJ);

		/* delete a bunch of objects */
		for(n = 0, i = 0; i < N_OBJ; i += R_OBJ, n += 1)
			if(!dtdelete(dt, Obj+i))
				terror("delete %s: i=%d",
					k == 0 ? "bag" : "obag", i);

		count = 0; /* count the left over */
		for(o = (Obj_t*)dtflatten(dt); o; o = (Obj_t*)dtlink(dt,o))
			count += 1;
		if(count != N_OBJ-n)
			terror("%s wrong count %d",
				k == 0 ? "bag" : "obag", count);

		dtclose(dt);
	}

	texit(0);
}
int main() {
  TEST_STRT(1);

  if(fork() == 0) {
    sleep(10); //Make sure the parent made it to wait();
    texit();
  } else {
    wait();
    TEST_FINI();
  }
  exit();
}
예제 #10
0
파일: tvthread.c 프로젝트: att/ast
tmain() {
    UNUSED(argc);
    UNUSED(argv);
    pthread_t thread[N_THREADS];
    size_t k, p, n;
    Mydisc_t disc[2];
    Obj_t *o, *list[2], obj;

    topts();

    /* create two dictionaries to volley objects back and forth */
    for (n = 0; n < 2; ++n) {
        if (!(Dict[n] = opendictionary(&disc[n]))) terror("Can't open dictionary %d", n);

        /* make objects */
        if (!(list[n] = malloc((N_OBJ / 2) * sizeof(Obj_t)))) terror("malloc failed %d", n);
        memset(list[n], 0, (N_OBJ / 2) * sizeof(Obj_t));

        for (o = list[n], k = 0; k < N_OBJ / 2; ++k, ++o) {
            o->value = n == 0 ? k : k + N_OBJ / 2;

            if (dtinsert(Dict[n], o) != o) terror("Insert failed n=%d k=%d", n, k);
            if (dtsearch(Dict[n], o) != o) { /* verify insert succeeded */
                terror("Search failed n=%d k=%d", n, k);
            }

            o->ins[n] += 1;
        }
    }

    for (p = 0; p < N_THREADS; ++p) pthread_create(&thread[p], 0, volley, (void *)((long)(p % 2)));

    for (p = 0; p < N_THREADS; ++p) pthread_join(thread[p], 0);

    tinfo("\tCheck integrity");
    n = dtsize(Dict[0]);
    p = dtsize(Dict[1]);
    tinfo("Dict[0]=%d Dict[1]=%d", n, p);
    if ((n + p) != N_OBJ) {
        for (k = 0; k < N_OBJ; ++k) {
            obj.value = k;
            if ((o = dtsearch(Dict[0], &obj))) continue;
            if ((o = dtsearch(Dict[1], &obj))) continue;
            terror("%d not found", k);
            dtsearch(Dict[0], &obj);
            dtsearch(Dict[1], &obj);
        }

        terror("Expecting %d objects but got (Dict[0]=%d + Dict[1]=%d) = %d", N_OBJ, n, p, n + p);
    }

    texit(0);
}
예제 #11
0
// Create a new CONS_TYPE value node.
Value *cons(Value *car, Value *cdr){
    if (car == NULL || cdr == NULL) {
        printf("Error: Cannot cons to null\n");
        texit(EXIT_FAILURE);
    }
    Value *node;
    node = talloc(sizeof(Value));
    node->type = CONS_TYPE;
    node->c.car = car;
    node->c.cdr = cdr;
    return node;
}
예제 #12
0
tmain()
{
	char	buf[100];
	Sfio_t	*fp;
	int	i;
	char	*s;

	if(!(fp = sftmp(8)))
		terror("Can't open temp file");

	sfset(fp,SF_LINE,1);
	for(i = 0; i < 1000; ++i)
	{	sfsprintf(buf,sizeof(buf),"Number: %d",i);
		if(sfputr(fp,buf,'\n') <= 0)
			terror("Writing %s",buf);
	}

	sfseek(fp,(Sfoff_t)0,0);

	for(i = 0; i < 1000; ++i)
	{	sfsprintf(buf,sizeof(buf),"Number: %d",i);
		if(!(s = sfgetr(fp,'\n',1)))
			terror("Reading %s",buf);
		if(strcmp(s,buf) != 0)
			terror("Input=%s, Expect=%s",s,buf);
	}

	sfseek(fp,(Sfoff_t)0,0);
	s = sfgetr(fp,'\0',1);
	if(s)
		terror("Expecting a null string");
	s = sfgetr(fp,'\0',-1);
	if(!s)
		terror("Expecting a non-null string");
	if(sfvalue(fp) != sfsize(fp))
		terror("Wrong size");

	sfclose(fp);
	if(!(fp = sfnew(0, buf, 12, 1, SF_WRITE)) )
		terror("Opening a test stream");
	sfsetbuf(fp, buf, 12);
	sfset(fp, SF_LINE, 0);
	sfdisc(fp, &Disc);
	if(sfputr(fp, "0123456789", '\n') != 11)
		terror("Sfputr failed1");
	if(sfputr(fp, "0", -1) != 1)
		terror("Sfputr failed2");
	if(sfputr(fp, "1", -1) != 1)
		terror("Sfputr failed3");

	texit(0);
}
예제 #13
0
파일: tinstall.c 프로젝트: att/ast
tmain() {
    UNUSED(argc);
    UNUSED(argv);
    Obj_t obj, chk1, chk2, chk22;
    Dt_t *dt;

    obj.key = 1;
    chk1.key = 1;
    chk2.key = 2;
    chk22.key = 2;

    if (!(dt = dtopen(&Disc, Dtoset))) terror("Can't open Dtoset dictionary");
    if (dtinsert(dt, &obj) != &obj) terror("dtinsert failed");
    if (dtinsert(dt, &chk1) != &obj) terror("dtinsert should have returned obj");
    if (dtinsert(dt, &chk2) != &chk2) terror("dtinsert should have returned chk2");
    if (dtinstall(dt, &chk1) != &chk1) terror("dtinstall should have returned chk1");

    if (!(dt = dtopen(&Disc, Dtobag))) terror("Can't open Dtobag dictionary");
    if (dtinsert(dt, &obj) != &obj) terror("dtinsert failed");
    if (dtinsert(dt, &chk1) != &chk1) terror("dtinsert should have returned chk1");
    if (dtinsert(dt, &chk2) != &chk2) terror("dtinsert should have returned chk2");
    if (dtinstall(dt, &chk1) != &chk1) terror("dtinsert should have returned chk1");
    if (dtinstall(dt, &chk22) != &chk22) terror("dtinsert should have returned chk22");

    if (!(dt = dtopen(&Disc, Dtset))) terror("Can't open Dtset dictionary");
    if (dtinsert(dt, &obj) != &obj) terror("dtinsert failed");
    if (dtinsert(dt, &chk1) != &obj) terror("dtinsert should have returned obj");
    if (dtinsert(dt, &chk2) != &chk2) terror("dtinsert should have returned chk2");
    if (dtinstall(dt, &chk1) != &chk1) terror("dtinsert should have returned chk1");

    if (!(dt = dtopen(&Disc, Dtbag))) terror("Can't open Dtbag dictionary");
    if (dtinsert(dt, &obj) != &obj) terror("dtinsert failed");
    if (dtinsert(dt, &chk1) != &chk1) terror("dtinsert should have returned chk1");
    if (dtinsert(dt, &chk2) != &chk2) terror("dtinsert should have returned chk2");
    if (dtinstall(dt, &chk1) != &chk1) terror("dtinsert should have returned chk1");
    if (dtinstall(dt, &chk22) != &chk22) terror("dtinsert should have returned chk22");

    if (!(dt = dtopen(&Disc, Dtrhset))) terror("Can't open Dtrhset dictionary");
    if (dtinsert(dt, &obj) != &obj) terror("dtinsert failed");
    if (dtinsert(dt, &chk1) != &obj) terror("dtinsert should have returned obj");
    if (dtinsert(dt, &chk2) != &chk2) terror("dtinsert should have returned chk2");
    if (dtinstall(dt, &chk1) != &chk1) terror("dtinsert should have returned chk1");

    if (!(dt = dtopen(&Disc, Dtrhbag))) terror("Can't open Dtrhbag dictionary");
    if (dtinsert(dt, &obj) != &obj) terror("dtinsert failed");
    if (dtinsert(dt, &chk1) != &chk1) terror("dtinsert should have returned chk1");
    if (dtinsert(dt, &chk2) != &chk2) terror("dtinsert should have returned chk2");
    if (dtinstall(dt, &chk1) != &chk1) terror("dtinsert should have returned chk1");
    if (dtinstall(dt, &chk22) != &chk22) terror("dtinsert should have returned chk22");

    texit(0);
}
예제 #14
0
파일: h2o.c 프로젝트: athai005/xv6_lab2
void oReady(void* v)
{
   sem_acquire(&h);
   sem_acquire(&h);
   sem_signal(&o);
   sem_signal(&o);
   sem_acquire(&l);
   water++;
   printf(1,"water molecule created\n");
   sem_signal(&l);

   texit();
}
예제 #15
0
Value *primitiveGreater(Value *args){
    //Exact same as less than but the comparison between the first and second value is changed to less than or equal to instead.
    if (length(args) != 2){
        printf("Evaluation Error: the number of arguments is not 2\n");
        texit(1);
    }
    Value *result = talloc(sizeof(Value));
    result->type = BOOL_TYPE;
    result->i = 1;
    double check;
    if (length(args) != 2) {
        printf("Evaluation Error: not a correct number of arguments\n");
        texit(1);
    }
    if (car(args)->type == INT_TYPE) {
        check = car(args)->i;
    } else if (car(args)->type == DOUBLE_TYPE) {
        check = car(args)->d;
    } else {
        printf("Evaluation Error: argument not a number\n");
        texit(1);
    }
    args = cdr(args);
    if (car(args)->type == INT_TYPE) {
        if (check <= car(args)->i) {
            result->i = 0;
            return result; 
        }
    } else if (car(args)->type == DOUBLE_TYPE) {
        if (check <= car(args)->d) {
            result->i = 0;
            return result;
        }
    } else {
        printf("Evaluation Error: argument not a number\n");
        texit(1);
    }
    return result;
}
예제 #16
0
파일: ts.c 프로젝트: liuhuac/OS
/* sub4: this thread also voluntarily releases the CPU with a
   tyield() call.
*/
void sub4() {
  int delay;
  while (tactive() > 2) {
      printf("sub4: tid=%p\n", tid());
      for (delay=0; delay<5000000; delay++) /*Do nothing delay loop */;
      for (delay=0; delay<5000000; delay++) /*Do nothing delay loop */;
      for (delay=0; delay<5000000; delay++) /*Do nothing delay loop */;
      for (delay=0; delay<5000000; delay++) /*Do nothing delay loop */;
      tyield();
  }
  printf(">>>sub 4 ending\n");
  texit();
}
예제 #17
0
파일: filter.cpp 프로젝트: ArtBears/wesnoth
void
filter_apply(surface& surf, const std::string& filter)
{
	std::vector<std::string> f = utils::split(filter, ':', utils::STRIP_SPACES);

	if(f.size() != 2) {
		std::cerr << "Error: Filter »"
				<< filter
				<< "« doesn't contain the expected separator »:«\n";

		throw texit(EXIT_FAILURE);
	}

	std::map<std::string, tfilter>::iterator itor = filters.find(f[0]);

	if(itor == filters.end()) {
		std::cerr << "Error: Filter »" << f[0] << "« is unknown.\n";
		throw texit(EXIT_FAILURE);
	}

	itor->second.functor(surf, f[1]);
}
예제 #18
0
파일: pathprog.c 프로젝트: att/ast
tmain() {
    UNUSED(argc);
    UNUSED(argv);

    char path[PATH_MAX];

    pathprog(argv[0], path, sizeof(path));

    if (strcmp(path, argv[0]))
        terror("pathprog() fails to return correct path. Expected: %s Actual: %s", path, argv[0]);

    texit(0);
}
예제 #19
0
파일: monkey.c 프로젝트: avana002/xv6_lab2
void monkey(void* v)
{
   int i = (int)v;
   while(dominant > 0);
   sem_acquire(&t);
   printf(1,"%d\n",i);
   coconuts++;
   int j;
   for(j = 0; j < 100000; j++);
   printf(1,"%d\n",i);
   sem_signal(&t);
   texit();
}
예제 #20
0
void MissionaryArrives()
{
	sem_aquire(&boat);
	
	sem_aquire(&display);
	printf(1, "1: (%d) missionary arrived, %d, %d\n", getpid(), total, con);
	sem_signal(&display);


	sem_aquire(&mutex2);	
	while(total + 1 == 5){ con++;
	sem_signal(&mutex2);
	sem_signal(&boat);

	sem_aquire(&display);
	printf(1, "1: (%d) missionary denied boarding, %d, %d\n", getpid(), total, con);
	sem_signal(&display);

	sem_aquire(&prevention);

	sem_aquire(&display);
	printf(1, "1: (%d) missionary prevented death, %d, %d\n", getpid(), total, con);
	sem_signal(&display);
	
	sem_aquire(&boat);
	sem_aquire(&mutex2);
	}
	sem_signal(&mutex2);
	sem_aquire(&mutex2);
	total += 1;
	sem_signal(&mutex2);
	
	sem_aquire(&display);
	printf(1, "2: (%d) missionary enters boat, %d, %d\n", getpid(), total, con);
	sem_signal(&display);

	sem_aquire(&mutex);
	bp++;
	sem_signal(&mutex);
	if (bp < 3)	sem_aquire(&loading);

	// sem_aquire(&display);
	// printf(1, "bp missionary: %d\n", bp);
	// sem_signal(&display);
	
	RowBoat();
	sem_signal(&loading);
	
	
	texit();
}
예제 #21
0
//checks numerical equality
Value *primitiveEqual(Value *args){
    //like before, create a double type called check that is the first value then compare it to all the other arguments in the while loop.
    Value *result = talloc(sizeof(Value));
    result->type = BOOL_TYPE;
    result->i = 1;
    double check;
    if (length(args) < 2) {
        printf("Evaluation Error: not enough arguments\n");
        texit(1);
    }
    if (car(args)->type == INT_TYPE) {
        check = car(args)->i;
    } else if (car(args)->type == DOUBLE_TYPE) {
        check = car(args)->d;
    } else {
        printf("Evaluation Error: argument not a number\n");
        texit(1);
    }
    args = cdr(args);
    while (args->type != NULL_TYPE) {
        if (car(args)->type == INT_TYPE) {
            if (check != car(args)->i) {
                result->i = 0;
                return result; 
            }
        } else if (car(args)->type == DOUBLE_TYPE) {
            if (check != car(args)->d) {
                result->i = 0;
                return result;
            }
        } else {
            printf("Evaluation Error: argument not a number\n");
            texit(1);
        }
        args = cdr(args);
    } 
    return result;
}
예제 #22
0
int
main (void)
{
  volatile int i = 0;
  if (i)
    tabort ();
  if (i)
    texit ();
  if (i)
    t_exit ();
  if (i)
    t_Exit ();
  exit (0);
}
예제 #23
0
void dmonkey(void* m) {
    dominantMonkey++;
    sema_acquire(tree);
    //printf(1,"Monkey acq Count: %d\n", tree->count);
    printf(1,"Dominant Monkey UP\n");
    int i = 0;
    int coconutTimer = random(99999) + 500000;
    for(;i < coconutTimer; i++){}
    printf(1,"Dominant Monkey DOWN\n");
    sema_signal(tree);
    dominantMonkey--;
    //printf(1,"Monkey sig Count: %d\n", tree->count);
    texit();
}
예제 #24
0
파일: monkey.c 프로젝트: avana002/xv6_lab2
void dmonkey(void* v)
{
   int i = (int)v;
   dominant++;
   sem_acquire(&t);
   dominant--;
   printf(1,"d%d\n",i);
   coconuts++;
   int j;
   for(j = 0; j < 100000; j++);
   printf(1,"d%d\n",i);
   sem_signal(&t);
   texit();
}
예제 #25
0
void monkey(void* m) {
    int num = (int)m;
    while(dominantMonkey != 0){}
    sema_acquire(tree);
    //printf(1,"Monkey acq Count: %d\n", tree->count);
    printf(1,"Monkey #%d UP\n", num);
    int i = 0;
    int coconutTimer = random(99999) + 500000;
    for(;i < coconutTimer; i++){}
    printf(1,"Monkey $%d DOWN\n",num);
    sema_signal(tree);
    //printf(1,"Monkey sig Count: %d\n", tree->count);
    texit();
}
예제 #26
0
파일: filter.cpp 프로젝트: ArtBears/wesnoth
static void
scale(surface& surf, const std::string& parameters)
{
	unsigned width, height;
	const int count = sscanf(parameters.c_str(), "%u,%u", &width, &height);

	if(count != 2) {
		std::cerr << "Error: Arguments to scale »"
				<< parameters
				<< "« are not compatible.\n";
		throw texit(EXIT_FAILURE);
	}

	surf = scale_surface(surf, width, height);
}
예제 #27
0
파일: strlcat.c 프로젝트: att/ast
tmain() {
    UNUSED(argc);
    UNUSED(argv);

    char buffer[7] = "foo";
    char buffer_to_append[] = "barbaz";

    strlcat(buffer, buffer_to_append, 7);

    if (strcmp(buffer, "foobar"))
        terror("strlcat() :: Failed to append buffer :: Actual Result: %s, Expected Result: %s",
               buffer, "foobar");

    texit(0);
}
예제 #28
0
파일: ts.c 프로젝트: liuhuac/OS
/* sub3: Test child thread */
void sub3() {
  int i,delay;
  for (i=0; i<25; i++) {
   printf("Hello from sub 3, loop %d\n",i); fflush(stdout);
   for (delay=0; delay<1000000; delay++) /*Do nothing delay loop */;
   for (delay=0; delay<1000000; delay++) /*Do nothing delay loop */;
   for (delay=0; delay<1000000; delay++) /*Do nothing delay loop */;
   for (delay=0; delay<1000000; delay++) /*Do nothing delay loop */;
   for (delay=0; delay<1000000; delay++) /*Do nothing delay loop */;
   for (delay=0; delay<1000000; delay++) /*Do nothing delay loop */;
   for (delay=0; delay<1000000; delay++) /*Do nothing delay loop */;
  }
  printf(">>>sub 3 ending\n");
  texit();
}
예제 #29
0
파일: filter.cpp 프로젝트: ArtBears/wesnoth
static void
brighten(surface& surf, const std::string& parameters)
{
	float amount;
	const int count = sscanf(parameters.c_str(), "%f", &amount);

	if(count != 1) {
		std::cerr << "Error: Arguments to brighten »"
				<< parameters
				<< "« are not compatible.\n";

		throw texit(EXIT_FAILURE);
	}

	surf = brighten_image(surf, amount);
}
예제 #30
0
Value *primitiveNull(Value *args){
    //Simply checks the type of the value * object being passed and returns true if it is null.
    if (length(args) != 1){
        printf("Evaluation Error: the number of arguments is not 1\n");
        texit(1);
    }
    Value *boolean = talloc(sizeof(Value));
    boolean->type = BOOL_TYPE;
    if (car(args)->type == NULL_TYPE){
        boolean->i = 1;
    }  
    else{
        boolean->i = 0;
    }
    return boolean;
}