コード例 #1
0
ファイル: primer.c プロジェクト: Aresthu/ucore_plus
int main(void)
{
	note = safe_shmem_malloc(total * sizeof(int));
	locks = safe_shmem_malloc(total * sizeof(lock_t));

	int i, pid;
	for (i = 0; i < total; i++) {
		note[i] = 0;
		lock_init(locks + i);
	}

	cprintf("sharemem init ok.\n");

	unsigned int time = gettime_msec();

	if ((pid = fork()) == 0) {
		primeproc();
		exit(0);
	}
	assert(pid > 0);

	for (i = 2;; i++) {
		if (write(0, i, 0) != 0) {
			break;
		}
	}

	cprintf("use %d msecs.\n", gettime_msec() - time);
	cprintf("primer pass.\n");
	return 0;
}
コード例 #2
0
ファイル: primes.c プロジェクト: BGCX262/zt-jos-svn-to-git
void
umain(void)
{
	int i, id;

	// fork the first prime process in the chain
	if ((id=fork()) < 0)
		panic("fork: %e", id);
	if (id == 0)
		primeproc();

	// feed all the integers through
	for (i=2;; i++)
		ipc_send(id, i, 0, 0);
}