コード例 #1
0
ファイル: defeq_canonizer.cpp プロジェクト: avigad/lean
expr defeq_canonizer::canonize_core(expr const & e) {
    if (auto it = m_state.m_C.find(e)) {
        expr e1 = *it;
        if (e1 == e)
            return e;
        expr e2 = canonize_core(e1);
        if (e2 != e1) {
            replace_C(e, e2);
        }
        return e2;
    }
    expr e_type  = m_ctx.infer(e);
    optional<name> h = get_head_symbol(e_type);
    if (!h) {
        /* canonization is not support for type of e */
        insert_C(e, e);
        return e;
    } else if (optional<expr> new_e = find_defeq(*h, e)) {
        if (get_weight(e) < get_weight(*new_e) && locals_subset(e, *new_e)) {
            replace_C(*new_e, e);
            replace_M(*h, *new_e, e);
            insert_C(e, e);
            return e;
        } else {
            insert_C(e, *new_e);
            return *new_e;
        }
    } else {
        insert_C(e, e);
        insert_M(*h, e);
        return e;
    }
}
コード例 #2
0
ファイル: pcb.cpp プロジェクト: wengduo/item
void roundsch_AB(ANODE *phead, BNODE *head, CNODE *hd)
{
	if (phead->next == NULL)
	{
		printf("无进程\n");
	}

	ANODE *p = phead->next;
	while (1)
	{
		my_diaodu(phead, head);
		
		if (head->next != NULL)
		{
			int n = 2;
			while (n--)
			{
				my_zhixing(head);
				BNODE *p1 = head->next;
				if (p1 != NULL)
				{
					if (p1->pcb.NEEDTIME != 0)
					{
						p1->prev->next = p1->next;
						if (p1->next == NULL)
						{
							head->next = p1;
						}
						else
						{
							head->tail->next = p1;//error
							p1->next = NULL;
							p1->prev = head->tail;
							head->tail = p1;
						}
					}
					else
					{
						insert_C(hd, p1);
						p1->prev->next = p1->next;
						free(p1);
					}
				}

				phead->COUNT++;
				my_diaodu(phead, head);
			}

			phead->CPUTIME++;
			printf("第%d次时间轮转\n", phead->CPUTIME);
			if (phead->next != NULL)
			{
				display_A(phead);
			}
			if (head->next != NULL)
			{
				display_B(head);
			}
			if (hd->next != NULL)
			{
				display_C(hd);
			}
		}

		phead->COUNT++;
		if (CNODE_length(hd) == 2)
		{
			break;
		}
	}
}