コード例 #1
0
ファイル: irq34.c プロジェクト: bicepjai/nanos
char DeCharQ(char_q_t *p) // return 0/null if queue is empty
{
    char ch;

    if(CharEmptyQ(p))
    {
        cons_printf("Char queue is empty, can't dequeue!\n");
        return 0; // return null char instead of -1 since the return type is char
    }
    ch = p->q[p->head];
    p->head++;
    if(p->head == CHAR_Q_SIZE) p->head = 0; // wrap
    p->count--;

    return ch;
}
コード例 #2
0
char CharDeQ(char_q_t *p) // return -1 if queue is empty
{
   char id;

   if(CharEmptyQ(p))
   {
      cons_printf("Queue is empty, can't dequeue!\n");
      return -1;
   }
   id = p->q[p->head];
   p->head++;
   if(p->head == Q_SIZE) p->head = 0;   // wrap around
   p->count--;

   return id;
}
コード例 #3
0
ファイル: irq34.c プロジェクト: bicepjai/nanos
//
// remove char from out_q and send it out via UART
//
void IRQ34ISROutChar(int term_num)
{
    char ch;

    terminals[term_num].missed_intr = FALSE;

    if(CharEmptyQ(&terminals[term_num].out_q) /*&&
      CharEmptyQ(&terminals[term_num].echo_q)*/)
    {
// nothing to display but the xmitter is ready, missed a chance to send a char
        terminals[term_num].missed_intr = TRUE; // set it so can use output later
        return;                                 // nothing more to do more
    }
    ch = DeCharQ(&terminals[term_num].out_q); // get a char from out queue
    //printf("\nch <= %c",ch);
    outportb(terminals[term_num].io_base + DATA, ch); // output ch to UART
    SemPostISR(terminals[term_num].out_sid);  // post a space (char)
}
コード例 #4
0
ファイル: q_mgmt.c プロジェクト: OnelungBL/CSC-159
char CharDeQ(char_q_t *p) // return -1 if q is empty
{
	char result;

	if (CharEmptyQ(p)) {
		cons_printf("Queue is empty, can't dequeue!\n");
		return -1;
	}

	result = p->q[p->head];

	p->head += 1;

	if (p->head >= Q_SIZE) {
		p->head = 0;
	}

	p->count -= 1;

	return result;
}