Пример #1
0
// remove multiple pages
// analogue to palloc_free_multiple
void
frame_remove_mult(void *frame_address,
                  size_t cnt) {
    // only one page at a time requestable
    ASSERT(cnt == 1);
    frame_remove(frame_address);
}
Пример #2
0
void
float_detach(Frame *f) {
	Frame *pr;
	Area *a, *sel, *oldsel;
	View *v;

	v = f->view;
	a = f->area;
	sel = view_findarea(v, v->selscreen, v->selcol, false);
	oldsel = v->oldsel;
	pr = f->aprev;

	frame_remove(f);

	if(a->sel == f) {
		while(pr && pr->client->nofocus)
			pr = pr->aprev;
		if(!pr)
			for(pr=a->frame; pr && pr->anext; pr=pr->anext)
				if(!pr->client->nofocus) break;
		a->sel = nil;
		area_setsel(a, pr);
	}
	f->area = nil;

	if(oldsel)
		area_focus(oldsel);
	else if(!a->frame || pr && pr->client->nofocus)
		if(sel && sel->frame)
			area_focus(sel);
}
Пример #3
0
void
column_remove(Frame *f) {
	Frame *pr;
	Area *a;

	a = f->area;
	pr = f->aprev;

	frame_remove(f);

	f->area = nil;
	if(a->sel == f) {
		if(pr == nil)
			pr = a->frame;
		if(pr && pr->collapsed)
			if(pr->anext && !pr->anext->collapsed)
				pr = pr->anext;
			else
				pr->collapsed = false;
		a->sel = nil;
		area_setsel(a, pr);
	}
}
Пример #4
0
void frame_evict_page(){
	uint8_t *kpage;
	struct frame_table_entry* fte;
	fte = clock_kick();
	ASSERT(fte!=NULL)
	// pin the page in case race condition!
	ASSERT(fte->pg_vaddr!=NULL)
	ASSERT(fte->kpg_vaddr!=NULL)
	ASSERT(pg_ofs(fte->pg_vaddr) == 0)
	ASSERT(fte->owner!=NULL)
	struct spte* spte = spt_lookup(fte->owner,fte->pg_vaddr);
	ASSERT(spte!=NULL)
	ASSERT(spte->fte!=NULL)
	ASSERT(spte->fte==fte)
	/*
	 * TODO:
	 * Copy the page to storage 'type',
	 * record missing page info into SPT
	 * after all, set PTE present = 0,
	 * Then remove the page from frame control,
	 */
//	printf("pg_vaddr = %p\n", fte->pg_vaddr);
	switch (spte->type) {
	case Swap_Space:
		;
//		printf("moving %p to swap\n",fte->pg_vaddr);
		int offs = swap_store_pg(fte->kpg_vaddr);
		spte->offs = offs;
		spte->mapped = false;
		spte->fte = NULL;
//		printf("Store to Swap_Space\n");
//		hex_dump(fte->pg_vaddr, fte->pg_vaddr,4096,true);
//		printf("\n");
		break;
	case File_Map:
		;
		/*
		 * write the page back to file, if necessary,
		 * mmap use only, never write back to an executable!
		 */
		struct file* f = spte->file;
		if (f != NULL) {
			if (spte->writable) {
				file_seek(f, spte->offs);
				file_write(f, fte->kpg_vaddr, PGSIZE);
			}
		}
		spte->mapped = false;
		spte->fte = NULL;
		break;
	case Data:
	case BSS:
		PANIC("Data or BSS should be transformed to Swap_Space");
		break;
	case Read_Only:
		// for a read only file, just discard the data
//		printf("evict read only page %p\n",fte->pg_vaddr);
		spte->mapped = false;
		spte->fte = NULL;
		break;
	default:
		;
//		printf("evict unknown page %p\n",fte->pg_vaddr);
		PANIC("evict unknown page");
	}
	frame_remove(fte);
}