Example #1
0
static IEntry*
poplast(IEntry *list)
{
	if(list->prev == list)
		return nil;
	return popout(list->prev);
}
Example #2
0
static IEntry*
pushfirst(IEntry *list, IEntry *ie)
{
	popout(ie);
	ie->prev = list;
	ie->next = list->next;
	ie->prev->next = ie;
	ie->next->prev = ie;
	return ie;
}
Example #3
0
static CEntry*
evict(Cache *c)
{
	CEntry *e;
	
	e = c->tail;
	popout(c, e);
	c->cefree(e);
	free(e->name);
	e->name = nil;
	memset(e, 0, c->sizeofentry);
	insertfront(c, e);
	return e;
}
Example #4
0
void
cacheflush(Cache *c, char *substr)
{
	CEntry **l, *e;
	int i;
	
	for(i=0; i<c->nhash; i++){
		for(l=&c->hash[i]; (e=*l); ){
			if(substr == nil || strstr(e->name, substr)){
				*l = e->hash.next;
				c->nentry--;
				popout(c, e);
				c->cefree(e);
				free(e->name);
				free(e);
			}else
				l = &e->hash.next;
		}
	}
}
Example #5
0
/*
 * The singly-linked non-circular list of index entries ie
 * has been written to disk.  Move them to the clean list.
 */
void
icacheclean(IEntry *ie)
{
	IEntry *next;
	
	trace(TraceProc, "icacheclean enter");
	qlock(&icache.lock);
	for(; ie; ie=next){
		assert(ie->state == IEDirty);
		next = ie->nextdirty;
		ie->nextdirty = nil;
		popout(ie); /* from icache.dirty */
		icache.ndirty--;
		ie->state = IEClean;
		pushfirst(&icache.clean, ie);
	}
	setstat(StatIcacheDirty, icache.ndirty);
	rwakeupall(&icache.full);
	qunlock(&icache.lock);
	trace(TraceProc, "icacheclean exit");
}
Example #6
0
static void
movetofront(Cache *c, CEntry *e)
{
	popout(c, e);
	insertfront(c, e);	
}
Example #7
0
int main()
{
	printf("The productions used are:\n");
	printf("E-->E*E/E+E/E^E/E*E/E-E\n E-->E/E \n E-->a/b/c/d/e.../z");
	printf("\n Enter an expression that terminals with $:");
	fflush(stdin);
	i=-1;
	while(str[i]!='$')
	{
		i++;
		scanf("%c",&str[i]);
	}

	for(j=0;j<i;j++)
	{
		if((str[j]=='(')||(str[j]==')')||(str[j+1]=='(')||(str[j+1]==')'))
		{}
		else if (((isalpha(str[j])==0)&&(isalpha(str[j+1])==0))||((isalpha(str[j])!=0)&&(isalpha(str[j+1])!=0)))
		{
			printf("ERROR");
			exit(0);
		}
	}
	if((((isalpha(str[0]))!=0)||(str[0]=='('))&&(((isalpha(str[i-1]))!=0)||(str[i-1]==')')))
	{
		pushin('$');
		printf("\n\n\n\t+\t-\t*\t/\t^\ta\t(\t)\t$\n\n");
		for(i=0;i<9;i++)
		{
			printf("%c",c[i]);
			for(j=0;j<9;j++)
				printf("\t%c",q[i][j]);
			printf("\n");
		}

		while(1)
		{
			if(str[ptr]=='$' && stk[tos]=='$')
			{
				printf("\n The given expression is succesfully accepted!\n");
				break;
			}
			else if(rel(stk[tos],str[ptr],'<')||rel(stk[tos],str[ptr],'=='))
			{
				display(str[ptr]);
				pushin(str[ptr]);
				ptr++;
			}
			else if(rel(stk[tos],str[ptr],'>'))
			{
				do
				{
					rm++;
					pstk[rm]=popout();
					display1(pstk[rm]);
				}

				while(!rel(stk[tos],pstk[rm],'<'));
			}

			else
			{
				printf("\n NOT ACCEPTED!!!!!!!\n");
				exit(1);
			}
		}
	}
	else
	{
		printf("ERROR");
	}
	return 0;
}