예제 #1
0
파일: vmm.c 프로젝트: akaros/vmm-akaros
void *timer_thread(void *arg)
{
	int fd = open("#cons/vmctl", O_RDWR), ret;
	int initcount;

	fprintf(stderr, "TIMER THREAD START 0x%llx\n", vmctl.timer_msr);

	// We only begin injection when linux writes a non zero initial count
	initcount = vmctl.initial_count;
	while (!initcount) {
		uthread_usleep(10000);
		initcount = vmctl.initial_count;
	}
	fprintf(stderr, "INJECTING TIMER 0x%llx\n", vmctl.timer_msr);

	fflush(stderr);
	while (1) {
		if (initcount) {
			set_posted_interrupt(vmctl.timer_msr & 0xff);
			//set_posted_interrupt(0xff);
			pwrite(fd, &vmctl, sizeof(vmctl), 1<<12);
		}
		uthread_usleep(10000);
		// check initcount again to make sure linux still wants it
		initcount = vmctl.initial_count;
	}
	close(fd);
}
예제 #2
0
void *timer_thread(void *arg)
{
	while (1) {
		set_posted_interrupt(0xef);
		ros_syscall(SYS_vmm_poke_guest, 0, 0, 0, 0, 0, 0);
		uthread_usleep(100000);
	}
	fprintf(stderr, "SENDING TIMER\n");
}
예제 #3
0
파일: ping.c 프로젝트: rajuvindane/akaros
void
sender(int fd, int msglen, int interval, int n)
{
	int i, extra;
	uint16_t seq;
	char *buf = malloc(BUFSIZE);
	uint8_t me[IPaddrlen], mev4[IPv4addrlen];
	struct icmphdr *icmp;
	Req *r;

	firstseq = seq = rand();

	icmp = geticmp(buf);
	memset(buf, 0, proto->iphdrsz + ICMP_HDRSIZE);
	for(i = proto->iphdrsz + ICMP_HDRSIZE; i < msglen; i++)
		buf[i] = i;
	icmp->type = proto->echocmd;
	icmp->code = 0;

	/* arguably the kernel should fill in the right src addr. */
	myipvnaddr(me, proto, network);
	if (proto->version == 4) {
		v6tov4(mev4, me);
		memmove(((struct ip4hdr *)buf)->src, mev4, IPv4addrlen);
	} else
		ipmove(((struct ip6hdr *)buf)->src, me);
	if (addresses)
		printf("\t%i -> %s\n", me, target);

	if(pingrint != 0 && interval <= 0)
		pingrint = 0;
	extra = 0;
	for(i = 0; i < n; i++){
		if(i != 0){
			if(pingrint != 0)
				extra = rand();
			/* uth_sleep takes seconds, interval is in ms */
			uthread_usleep((interval + extra) * 1000);
		}
		r = calloc(sizeof *r, 1);
		if (r == NULL){
			printf("out of memory? \n");
			break;
		}
		hnputs(icmp->seq, seq);
		r->seq = seq;
		r->next = NULL;
		r->replied = 0;
		r->tsctime = read_tsc();	/* avoid early free in reply! */
		spin_pdr_lock(&listlock);
		if(first == NULL)
			first = r;
		else
			last->next = r;
		last = r;
		spin_pdr_unlock(&listlock);
		r->tsctime = read_tsc();
		if(write(fd, buf, msglen) < msglen){
			fprintf(stderr, "%s: write failed: %r\n", argv0);
			return;
		}
		seq++;
	}
	done = 1;
}