Example #1
0
void
swapDriver(void)
{
  release(&ptable.lock);
  struct proc* p;
  
  while(1){
    //cprintf("[c=%d]", ins_work);
    // Loop over process table looking for process 
    // SLEEPING_SUSPENDED or RUNNABLE_SUSPENDED
    //acquire(&inswapper_lk);
    acquire(&ptable.lock);
    for(p = ptable.proc; p < &ptable.proc[NPROC] && ins_enabled == 1; p++){
      if((p->state != SLEEPING && p->state != RUNNABLE_SUSPENDED) || p->io_sleep == 1)
        continue;
      if(p->pid <= 3)
        continue;
      
      p->swapping = 1;
      if(p->state == SLEEPING){
        // Swap Memory to Hard Drive
        //acquire(&inswapper_lk);
        //cprintf("ss");
        swapOut(p);
        p->state = SLEEPING_SUSPENDED;
        //release(&inswapper_lk);
      } else {
        // Swap Memory from Hard Drive
        //acquire(&inswapper_lk);
        //cprintf("rr");
        swapIn(p);
        p->state = RUNNABLE;
        //release(&inswapper_lk);
      }
      if(p->needs_swapin == 1){
        swapIn(p);
        p->needs_swapin = 0;
        p->state = RUNNABLE;
      }
      p->swapping = 0;
      //wakeup(&inswapper);
      //cprintf("[insw=%d]", ins_work);
    }
    
    if(ins_work <= 0 || ins_enabled == 0){
      // no work needed - goto sleep
      ins_work = 0;
      proc->state = SLEEPING;
      //release(&inswapper_lk);
      sched();
    }
    release(&ptable.lock);
    //release(&inswapper_lk);
  }
}
Example #2
0
void KateBufBlock::removeLine(uint i)
{
  // take care that the string list is around !!!
  if (m_state == KateBufBlock::stateSwapped)
    swapIn ();

  m_stringList.erase (m_stringList.begin()+i);
  m_lines--;

  markDirty ();
}
Example #3
0
void KateBufBlock::insertLine(uint i, KateTextLine::Ptr line)
{
  // take care that the string list is around !!!
  if (m_state == KateBufBlock::stateSwapped)
    swapIn ();

  m_stringList.insert (m_stringList.begin()+i, line);
  m_lines++;

  markDirty ();
}
Example #4
0
KateTextLine::Ptr KateBufBlock::line(uint i)
{
  // take care that the string list is around !!!
  if (m_state == KateBufBlock::stateSwapped)
    swapIn ();

  // LRU
  if (!m_parent->m_loadedBlocks.isLast(this))
    m_parent->m_loadedBlocks.append (this);

  return m_stringList[i];
}
Example #5
0
void MemoryManager::executeCycle() {
	++_m_cycle_num;

	for (unsigned long i = 0; i < _running_queue.size(); ++i) {

		process_t& _proc = _running_queue[i];
		_proc._burst_time = (_proc._burst_time - 1);
		if (_proc._burst_time == 0) {
			_proc._can_swap_out = true;
		}
	}

	if (hasReadyProcess()) {
		if (swapIn(pullNextFromReadyQueue())) {
			_ready_queue.erase(_ready_queue.begin());
		} else {
			bool proc_swapped = false;
			for (unsigned long i = 0; i < _running_queue.size(); i++) {
				process_t& _proc = _running_queue[i];
				if (_proc._can_swap_out) {
					if (swapOut(_proc)) {
						_proc._can_swap_out = false;
						_proc._can_swap_in = true;
						_ready_queue.push_back(_running_queue.at(i));
						_running_queue.erase(_running_queue.begin() + i);
						proc_swapped = true;
					}
				}

				if (proc_swapped) {
					proc_swapped = false;
					break;
				}
			}
		}
	}

	double _ratio = getMemRatio();
	if (_ratio > MAX_MEM_RATION) {

		std::cout << "\tRUNNING COMPACTION - MAX RATIO HIT (" << _ratio << ")"
				<< std::endl;

		doCompaction();
		printMemMap();
	}

}
Example #6
0
File: proc.c Project: yonatana/OS
void inSwapper(){
  release(&ptable.lock);
  for(;;){
    struct proc *p;
    acquire(&ptable.lock);
    //cprintf("inSwapper\n");
    for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
      if(p->state == RUNNABLE_SUSPENDED && p->swapped){
	//cprintf("calling swapIn process %d\n",p->pid);
	swapIn(p);
	p->swapped = 0;
	p->state = RUNNABLE;
      }
    }
    proc->state = SLEEPING;
    //cprintf("inSwapper finished proc->pid %d\n",proc->pid);
    sched();
    release(&ptable.lock);
  }
}
Example #7
0
void
disableSwapping(){
  ins_enabled = 0;
  struct proc* p;
  
  acquire(&ptable.lock);
  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
    while(p->swapping == 1);
    if(p->state != SLEEPING_SUSPENDED && p->state != RUNNABLE_SUSPENDED)
      continue;
    
    p->swapping = 1;
    swapIn(p);
    if(p->state == SLEEPING_SUSPENDED){
      p->state = SLEEPING;
    } else {
      p->state = RUNNABLE;
    }
    p->swapping = 0;
  }
  release(&ptable.lock);
}
void ofxFBOTexture::begin() {
	swapIn();
	setupScreenForMe();
}
Example #9
0
int pageFaultAction(uint va) {
	pde_t *pgdir = proc->pgdir;
	swapOut(pgdir);
	swapIn(va);
	return 0;
}