示例#1
0
void Insert_Spline_Entry(GenericSpline * sp, DBL p, const EXPRESS& v)
{
    SplineEntryList::size_type i;
    int k;

    /* Reset the Coeffs_Computed flag.  Inserting a new point invalidates
     *  pre-computed coefficients */
    sp->Coeffs_Computed = false;
    i = findt(sp, p);
    /* If p is already in spline, replace */
    /* The clause after the || is needed because findt returns sp->SplineEntries.size()
     * if p is greater than OR EQUAL TO the highest par in the spline */
    if(!sp->SplineEntries.empty() && ((sp->SplineEntries[i].par == p) || (i == sp->SplineEntries.size() && sp->SplineEntries[i-1].par == p)))
    {
        for(k=0; k<5; k++)
            sp->SplineEntries[i].vec[k] = v[k];
    }
    else
    {
        mkfree(sp, i);
        sp->SplineEntries[i].par = p;

        for(k=0; k<5; k++)
            sp->SplineEntries[i].vec[k] = v[k];
    }
}
示例#2
0
void write_reg(int pid, int reg, int value, int type) {
	MKNode *lroot = root;
	while( ((Process *) lroot->value)-> pid != pid )
		lroot = lroot->next;
	((Process *) lroot->value)->shared_regs[reg] = value;
	((Process *) lroot->value)->type[reg] = type;
	((Process *) lroot->value)->genesis[reg] = current_process();
	lroot = NULL;
	mkfree(lroot);
}
示例#3
0
void kill(int pid) {
	MKNode *lroot = root;
        if( root != NULL ) {
                while( ( (Process *) lroot->next->value )->pid != pid )
                        lroot = lroot->next;
                lroot->next = lroot->next->next;
        }
        lroot = NULL;
        mkfree(lroot);
}
示例#4
0
int current_process() {
	MKNode *lroot = root;
	int pid;
	while( ( (Process *) lroot->value)->executing != 1)
		lroot = lroot->next;
	pid = ((Process *) lroot->value)->pid;
	lroot = NULL;
	mkfree(lroot);
	return pid;
}
示例#5
0
int read_genesis(int reg) {
	int pid = current_process();
	int r_genesis;
	MKNode *lroot = root;
	while( ((Process *) lroot->value)-> pid != pid )
		lroot = lroot->next;
	r_genesis = ((Process *) lroot->value)->genesis[reg];
	lroot = NULL;
	mkfree(lroot);
	return r_genesis;
}
示例#6
0
int read_type(int reg) {
	int pid = current_process();
	int r_type;
	MKNode *lroot = root;
	while( ((Process *) lroot->value)-> pid != pid )
		lroot = lroot->next;
	r_type = ((Process *) lroot->value)->type[reg];
	lroot = NULL;
	mkfree(lroot);
	return r_type;
}
示例#7
0
int read_reg(int reg) {
	int pid = current_process();
	int r_reg;
	MKNode *lroot = root;
	while( ((Process *) lroot->value)-> pid != pid )
		lroot = lroot->next;
	r_reg = ((Process *) lroot->value)->shared_regs[reg];
	lroot = NULL;
	mkfree(lroot);
	return r_reg;
}
示例#8
0
void push(MKNode *node) {
	MKNode *lroot = root;
	if(root != NULL){
		while(lroot->next != NULL)
			lroot = lroot->next;
		lroot->next = node;
	}else
		root = node;
	lroot = NULL;
	mkfree(lroot);
}
示例#9
0
void Insert_Spline_Entry(SPLINE * sp, DBL p, EXPRESS v)
{
    int i, k;

    /* Reset the Coeffs_Computed flag.  Inserting a new point invalidates 
     *  pre-computed coefficients */
    sp->Coeffs_Computed = false;
    sp->Cache_Valid = false;
    /* If all space is used, reallocate */
    if(sp->Number_Of_Entries >= sp->Max_Entries)
    {
        sp->Max_Entries += INIT_SPLINE_SIZE;
        sp->SplineEntries = (SPLINE_ENTRY *)POV_REALLOC(sp->SplineEntries, sp->Max_Entries * sizeof(SPLINE_ENTRY), "Temporary Spline Entries");
        for (i = sp->Number_Of_Entries; i < sp->Max_Entries; i++)
        {
          sp->SplineEntries[i].par=-1e6;
        }
    }
    i = findt(sp, p);
    /* If p is already in spline, replace */
    /* The clause after the || is needed because findt returns sp->Number_Of_Entries
     * if p is greater than OR EQUAL TO the highest par in the spline */
    if(sp->Number_Of_Entries != 0 && ((sp->SplineEntries[i].par == p) || (i == sp->Number_Of_Entries && sp->SplineEntries[i-1].par == p)))
    {
        for(k=0; k<5; k++)
            sp->SplineEntries[i].vec[k] = v[k];
    }
    else
    {
        mkfree(sp, i);
        sp->SplineEntries[i].par = p;

        for(k=0; k<5; k++)
            sp->SplineEntries[i].vec[k] = v[k];

        sp->Number_Of_Entries += 1;
    }
}