示例#1
0
void arch_cpu_wait_for_action(void)
{
	struct cpu_info *ci = cpu_info();
	struct cpu_action_queue *q = &ci->action_queue;

	while (1) {
		struct cpu_action *orig;
		struct cpu_action action;

		orig = wait_for_action(q, &action);

		action_run(&action);
		action_queue_complete(q, orig);
	}
}
示例#2
0
/*
 *  get_blk(int phase) :  Empfange die BLK(phase) Daten
 */
header_p
get_blk(int phase)
{
	header_p p, c, s, last;
	char tme[6], blk[6];
	crc_t crc;
	unsigned int crc_hd;

	/*
	 *  Erwartete Blockarten (wegen Receive Window = 1 koennen hier
	 *  nur diese beiden oder NAK0 erscheinen).
	 */
	sprintf(tme, "TME%d", phase);
	sprintf(blk, "BLK%d", phase);

	last = NULL; p = NULL;
	while (1) {
		if (p) free_para(p);

		/*
		 *  Block einlesen
		 */
		p = rd_packet(stdin, &crc);

		c = find(HD_CRC, p);
		if (!c) {
			fputs("Paket ohne CRC empfangen...\n", deblogfile);
			continue;
		}

		sscanf(c->text, "%x", &crc_hd);
		if (crc != crc_hd) {
			fputs("Paket mit ungueltigem CRC empfangen...\n",
				deblogfile);
			send_nak();
			continue;
		}

		c = find(HD_LOGOFF, p);
		if (c) {
			fprintf(deblogfile,
				"Logoff-Anforderung durch "
				"die Gegenseite:\n\t\"%s\"\n\n",
				c->text);
			auflegen_empfangen = 1;
			auflegen = 1;
			send_ack(phase);
			return p;
		}
		s = find(HD_STATUS, p);
		if (!s) {
			fputs("Paket ohne STATUS empfangen...\n",
				deblogfile);
			continue;
		}

		if (phase == 4)
			fprintf(deblogfile, "[Phase 4] STATUS: %s\n", s->text);

		if (phase == 4 && (stricmp(s->text, "EOT4") == 0 ||
		    stricmp(s->text, "EOT5") == 0 ||
		    stricmp(s->text, "EOT6") == 0)) {
		    	fputs("Rufe wait_for_action\n", deblogfile);
			wait_for_action(p);
			if (p) free_para(p);
			return last;
		} else if (stricmp(s->text, blk) == 0) {
			send_ack(phase);
			if (last) free_para(last);
			last = p;
			p = NULL; /* p (und damit last) nicht freigeben */
			continue;
		} else if (stricmp(s->text, tme) == 0) {
			if (p) free_para(p);
			return last;
		} else if (stricmp(s->text, "NAK0") == 0) {
			fprintf(deblogfile,
				"NAK0 empangen beim Warten auf %s\n", blk);
			/*
			 *  Wir sollen wiederholen. Aber was?
			 *  Eigentlich wollen wir doch Daten kriegen...
			 */
			if (last)
				send_ack(phase); /* Ist sicher OK */
			else
				send_nak(); /* Das ist schon etwas komisch */
			continue;
		}
	}
}