Пример #1
0
static void parse_initstr(void)
{
//	struct cos_array *data;
	char *c;
	static int parsed = 0;

	if (parsed) return;
	parsed = 1;

	/* data = cos_argreg_alloc(sizeof(struct cos_array) + 52); */
	/* assert(data); */
	/* data->sz = 52; */
	
	/* if (sched_comp_config_initstr(cos_spd_id(), data)) { */
	/* 	printc("No initstr found.\n"); */
	/* 	return; */
	/* } */
	/* //printc("%s\n", data->mem); */

	/* c = data->mem; */
	c = cos_init_args();
	while ('\0' != *c) c = parse_step(c);
	
//	cos_argreg_free(data);
}
Пример #2
0
void
cos_init(void *arg)
{
	int c, accept_fd, ret;
	long eid;
	char *init_str = cos_init_args(), *create_str;
	int lag, nthds, prio;
	
	cvect_init_static(&evts);
	cvect_init_static(&tor_from);
	cvect_init_static(&tor_to);
	lock_static_init(&sc_lock);
		
	sscanf(init_str, "%d:%d:%d", &lag, &nthds, &prio);
	printc("lag: %d, nthds:%d, prio:%d\n", lag, nthds, prio);
	create_str = strstr(init_str, "/");
	assert(create_str);

	eid = evt_get();
	ret = c = from_tsplit(cos_spd_id(), td_root, create_str, strlen(create_str), TOR_ALL, eid);
	if (ret <= td_root) BUG();
	accept_fd = c;
	evt_add(c, eid);

	/* event loop... */
	while (1) {
		struct tor_conn tc;
		int t;
		long evt;

		memset(&tc, 0, sizeof(struct tor_conn));
		evt = evt_wait_all();
		t   = evt_torrent(evt);

		if (t > 0) {
			tc.feid = evt;
			tc.from = t;
			if (t == accept_fd) {
				tc.to = 0;
				accept_new(accept_fd);
			} else {
				tc.to = tor_get_to(t, &tc.teid);
				assert(tc.to > 0);
				from_data_new(&tc);
			}
		} else {
			t *= -1;
			tc.teid = evt;
			tc.to   = t;
			tc.from = tor_get_from(t, &tc.feid);
			assert(tc.from > 0);
			to_data_new(&tc);
		}

		cos_mpd_update();
	}
}
Пример #3
0
void
cos_init(void *arg)
{
	int c, accept_fd, ret;
	long eid;
	char *init_str = cos_init_args();
	char __create_str[128];
	static volatile int first = 1, off = 0;
	int port;
	u64_t start, end;

	if (cos_get_thd_id() == pid_thd) {
		pid_process();
	}
	
	union sched_param sp;

	if (first) {
		first = 0;

		sp.c.type = SCHEDP_PRIO;
		sp.c.value = 10;
		pid_thd = sched_create_thd(cos_spd_id(), sp.v, 0, 0);

		init(init_str);
		return;
	}


	printc("Thread %d, port %d\n", cos_get_thd_id(), __port+off);	
	port = off++;
	port += __port;
	eid = evt_get();
	if (snprintf(__create_str, 128, create_str, port) < 0) BUG();
	ret = c = from_tsplit(cos_spd_id(), td_root, __create_str, strlen(__create_str), TOR_ALL, eid);
	if (ret <= td_root) BUG();
	accept_fd = c;
	printc("accept_fd %d (eid %d)\n", accept_fd, eid);
	evt_add(c, eid);

	/* event loop... */
	while (1) {
		int t;
		long evt;
		
		evt = evt_wait_all();
		t   = evt_torrent(evt);
		printc("an interrupt comes in (thd %d, evt %d t %d)\n",
		       cos_get_thd_id(), evt, t);
		accept_new(accept_fd);
		break;
	}
}
Пример #4
0
void parse_args(int *p, int *n)
{
	char *c;
	int i = 0, s = 0;
	c = cos_init_args();
	while (c[i] != ' ') {
		s = 10*s+c[i]-'0';
		i++;
	}
	*p = s;
	s = 0;
	i++;
	while (c[i] != '\0') {
		s = 10*s+c[i]-'0';
		i++;
	}
	*n = s;
	return ;
}
int parse_initstr(void)
{
//	struct cos_array *data;
	char *c;

	c = cos_init_args();
	while ('\0' != *c) c = parse_step(c);

	/* data = cos_argreg_alloc(sizeof(struct cos_array) + 52); */
	/* assert(data); */
	/* data->sz = 52; */
	
	/* if (sched_comp_config_initstr(cos_spd_id(), data)) { */
	/* 	printc("No initstr found.\n"); */
	/* 	return -1; */
	/* } */

	/* c = data->mem; */
	/* while ('\0' != *c) c = parse_step(c); */
	
	/* cos_argreg_free(data); */

	return 0;
}