Esempio n. 1
0
void
console_init(void)
{
    initlock(&console_lock, "console");
    initlock(&input.lock, "console input");

    devsw[CONSOLE].write = console_write;
    devsw[CONSOLE].read = console_read;
    use_console_lock = 1;

    pic_enable(IRQ_KBD);
    ioapic_enable(IRQ_KBD, 0);
}
Esempio n. 2
0
void
consoleinit(void)
{
  initlock(&cons.lock, "console");
  initlock(&input.lock, "input");

  devsw[CONSOLE].write = consolewrite;
  devsw[CONSOLE].read = consoleread;
  cons.locking = 1;

  picenable(IRQ_KBD);
  ioapicenable(IRQ_KBD, 0);
}
Esempio n. 3
0
void
mouseinit(void)
{
    uchar statustemp;

    mouse_wait(1);
    outb(0x64, 0xa8);		//激活鼠标接口
    
    mouse_wait(1);		//激活中断
    outb(0x64, 0x20);
    mouse_wait(0);
    statustemp = (inb(0x60) | 2);
    mouse_wait(0);
    outb(0x64, 0x60);
    mouse_wait(1);
    outb(0x60, statustemp);

    mouse_write(0xf6);		//设置鼠标为默认设置
    mouse_read();

    mouse_write(0xf3);		//设置鼠标采样率
    mouse_read();
    mouse_write(10);
    mouse_read();
 
    mouse_write(0xf4);
    mouse_read();    

    initlock(&mouselock, "mouse");
    picenable(IRQ_MOUSE);
    ioapicenable(IRQ_MOUSE, 0);
    
    count = 0;
    lastclicktick = lastdowntick = -1000;
}
Esempio n. 4
0
File: pmap.c Progetto: ecros/xv6-vm
// Setup a two-level page table:
// 	boot_pgdir is the linear address of the root
// 	boot_cr3 is the physical address of the root
// After that turn on paging.
void
i386_vm_init(void)
{
	pde_t * pgdir;
	int i;
	// init physical memory allocation and deallocation spin lock
	initlock(&phy_mem_lock, "phy_mem");

	// create initial page directory , no need to acquire spin lock because
	// no other processors are running
	pgdir = (pde_t *)alloc_page();
	memset(pgdir, 0, PAGE);
	boot_pgdir = pgdir;
	boot_cr3 = (uint)pgdir;

	// turn the page directory into a page table so that all page table 
	// entries containing mappings for the entire space will be mapped 
	// into the 4 Meg region at VPT
	pgdir[PDX(VPT)] = boot_cr3 | PTE_W | PTE_P;
	pgdir[PDX(UVPT)] = boot_cr3 | PTE_U | PTE_P;

	// map the range of memory from 0~0x100000 to itself
	boot_map_segment(pgdir, 0, 0, 0x100000, PTE_U | PTE_W);
	for (i = 0; i < e820_memmap->nr_map; i ++) {
		uint addr = (uint)e820_memmap->map[i].addr;
		uint size = (uint)e820_memmap->map[i].size;
		if (addr >= 0x100000) {
			cprintf("map : %x,%x with size %x\n",(addr >> 16),(addr & 0xffff),size);
			boot_map_segment(pgdir, addr, addr, size, PTE_U | PTE_W); 
		}
	}
Esempio n. 5
0
// Initialization happens in two phases.
// 1. main() calls kinit1() while still using entrypgdir to place just
// the pages mapped by entrypgdir on free list.
// 2. main() calls kinit2() with the rest of the physical pages
// after installing a full page table that maps them on all cores.
void
kinit1(void *vstart, void *vend)
{
  initlock(&kmem.lock, "kmem");
  kmem.use_lock = 0;
  freerange(vstart, vend);
}
Esempio n. 6
0
int
binary_semaphore_create(int initial_value)
{
	if(!initialized)
		init_bsemaphores();
	
	if(!is_legal_id(next_bsemaphore))
		panic("binary semaphore overflow!");
	
	acquire(&list_lock);
	struct binary_semaphore *s = &bsemaphores[next_bsemaphore];
	
	initlock(&s->lock, "bsemaphore_lock");
	acquire(&s->lock);
	s->id=next_bsemaphore;
	int id=next_bsemaphore;
	if(initial_value<=0)
		s->value=0;
	else
		s->value=1;
	init_queue(&s->waiting);
	release(&s->lock);
	
	next_bsemaphore++;
	release(&list_lock);
	
	return id;
}
Esempio n. 7
0
File: proc.c Progetto: Minjun-Li/xv6
void
pinit(void)
{
  initlock(&ptable.lock, "ptable");
#ifndef __ORIGINAL_SCHED__
  pqueue_init();
#endif
}
Esempio n. 8
0
void
iinit(int dev)
{
  initlock(&icache.lock, "icache");
  readsb(dev, &sb);
  cprintf("sb: size %d nblocks %d ninodes %d nlog %d logstart %d inodestart %d bmap start %d\n", sb.size,
          sb.nblocks, sb.ninodes, sb.nlog, sb.logstart, sb.inodestart, sb.bmapstart);
}
Esempio n. 9
0
// Initialization happens in two phases.
// 1. main() calls kinit1() while still using entrypgdir to place just
// the pages mapped by entrypgdir on free list.
// 2. main() calls kinit2() with the rest of the physical pages
// after installing a full page table that maps them on all cores.
void
kinit1(void *vstart, void *vend)
{
    initlock(&kmem.lock, "kmem");
    kmem.use_lock = 0;
    freerange(vstart, vend);
	cprintf("+%x\n", kmem.freelist);
}
Esempio n. 10
0
void tvinit(void) {
	int i;

	for(i = 0; i < 256; i++)
		SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0);
	SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER);

	initlock(&tickslock, "time");
}
Esempio n. 11
0
// Per-CPU process scheduler.
// Each CPU calls scheduler() after setting itself up.
// Scheduler never returns.  It loops, doing:
//  - choose a process to run
//  - swtch to start running that process
//  - eventually that process transfers control
//      via swtch back to the scheduler.
void
scheduler(void)
{
  struct proc *p;
  initlock(&tlock, "time");


  for(;;){
    // Enable interrupts on this processor.
    sti();

    // Loop over process table looking for process to run.
    acquire(&ptable.lock);
    for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
      if(p->state != RUNNABLE)
        continue;

      if(count_high_pri() != 0 && p->priority == 1)
		continue;

      // Switch to chosen process.  It is the process's job
      // to release ptable.lock and then reacquire it
      // before jumping back to us.
      proc = p;
      switchuvm(p);
      p->state = RUNNING;
	  //swtch(&cpu->scheduler, proc->context);
	  //switchkvm();
	  uint ticks0 = 0, ticks1 = 0;
	  
	  acquire(&tlock);//Acquire the timer lock
      ticks0 = ticks;//Start timer
	  release(&tlock);

	  swtch(&cpu->scheduler, proc->context);

      acquire(&tlock);//Acquire the timer lock
      ticks1 = ticks;//Stop timer and add the ticks to htick or ltick depending upon the priority of the process.
      release(&tlock);

	  if (p->priority == 1) {
		p->ltick = p->ltick + (ticks1 - ticks0);
      } else {
		p->htick = p->htick + (ticks1 - ticks0);
	  }
	  
      switchkvm();

      // Process is done running for now.
      // It should have changed its p->state before coming back.
      proc = 0;
    }
    release(&ptable.lock);

  }
}
Esempio n. 12
0
File: kalloc.c Progetto: MyXOF/xv6
// Initialize free list of physical pages.
void
kinit(void)
{
  extern char end[];

  initlock(&kmem.lock, "kmem");
  char *p = (char*)PGROUNDUP((uint)end);
  for( ; p + PGSIZE - 1 < (char*) PHYSTOP; p += PGSIZE)
    kfree(p);
}
Esempio n. 13
0
// Initialize free list of physical pages.
void
kinit(void)
{
  char *p;

  initlock(&kmem.lock, "kmem");
  p = (char*)PGROUNDUP((uint)newend);
  for(; p + PGSIZE <= (char*)p2v(PHYSTOP); p += PGSIZE)
    kfree(p);
}
Esempio n. 14
0
void consoleinit(void) {
	initlock(&cons.lock, "console");
	historyList.size = 0;

	devsw[CONSOLE].write = consolewrite;
	devsw[CONSOLE].read = consoleread;
	cons.locking = 1;

	picenable(IRQ_KBD);
	ioapicenable(IRQ_KBD, 0);
}
Esempio n. 15
0
void
initmem1(void *start, void *end)
{
    initlock(&kmem.lock);
    kmem.freelist = 0;

    // interrupts aren't set up yet, so we can't call lock/unlock
    kmem.uselock = 0;

    freerange(start, end);
}
Esempio n. 16
0
void
pinit(void)
{
  initlock(&ptable.lock, "ptable");
  
  // START HW4
  // initialize ready queues for scheduler
  int i;
 
  initlock(&runqueue.lock, "runqueue");

  acquire(&runqueue.lock);
  for(i=0; i<NQUEUE; i++){ 
	//initlock( &runqueue.lock[i],  q_names[i]);
	runqueue.q[i] = 0;
  }
  release(&runqueue.lock);
  // END HW4 
  
}
Esempio n. 17
0
void
pinit(void)
{
  initlock(&ptable.lock, "ptable");
  //current_priority = 0;
  int i;
  for(i = 0; i < PRIORITIES; i ++)
    {
      ready[i] = 0;
    }
}
Esempio n. 18
0
int mtx_create(int locked){
  char* name = "mutex";
  //Check is a mutex is available
  if(mutexindex < NMUTEX){
    initlock(&mutexes[mutexindex], name);
    if(locked){
      mtx_lock(mutexindex);
    }
    return(mutexindex++);
  }
  return -1;
}
Esempio n. 19
0
void mouseinit()
{
  outb(0x64, 0xa8);
  outb(0x64, 0xd4);
  outb(0x60, 0xf4);
  outb(0x64, 0x60);
  outb(0x60, 0x47);
  setMousePosition(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
  initlock(&mouse_lock, "mouse");
  picenable(IRQ_MOUSE);
  ioapicenable(IRQ_MOUSE, 0);
}
Esempio n. 20
0
void
mouseinit()
{
    outb( 0x64 , 0xa8 );
    outb( 0x64 , 0xd4 );
    outb( 0x60 , 0xf4 );
    outb( 0x64 , 0x60 );
    outb( 0x60 , 0x47 );
    initlock(&mouse_lock,"mouse");
    picenable(IRQ_MOUS);
    ioapicenable(IRQ_MOUS, 0);
}
Esempio n. 21
0
void
pinit(void)
{
  initlock(&ptable.lock, "ptable");

  //part 2
  int i, j;
  for(i = 0 ; i < NPROC ; i++) {
    for(j = 0 ; j < 200 ; j++)
        unlockInodesTable[i][j] = 0;
  }

}
Esempio n. 22
0
void consoleinit(void)
{
uint fbinfoaddr;

  fbinfoaddr = initframebuf(framewidth, frameheight, framecolors);
  ///if(fbinfoaddr != 0) NotOkLoop();

  if(fbinfoaddr != 0) { uartputc('N'); while(1); }
  else uartputc('Y');

  initlock(&cons.lock, "console");
  memset(&input, 0, sizeof(input));
  initlock(&input.lock, "input");

  memset(devsw, 0, sizeof(struct devsw)*NDEV);
  devsw[CONSOLE].write = consolewrite;
  devsw[CONSOLE].read = consoleread;
  cons.locking = 1;
  panicked = 0; // must initialize in code since the compiler does not

  cursor_x=cursor_y=0;
}
Esempio n. 23
0
File: kalloc.c Progetto: HVNT/6.828
// Initialize free list of physical pages.
// This code cheats by just considering one megabyte of
// pages after end.  Real systems would determine the
// amount of memory available in the system and use it all.
void
kinit(void)
{
  extern char end[];
  uint len;
  char *p;

  initlock(&kmem.lock, "kmem");
  p = (char*)(((uint)end + PAGE) & ~(PAGE-1));
  len = 256*PAGE; // assume computer has 256 pages of RAM, 1 MB
  cprintf("mem = %d\n", len);
  kfree(p, len);
}
Esempio n. 24
0
stasis_log_t* stasis_log_impl_in_memory_open() {
  stasis_log_impl_in_memory * impl = malloc(sizeof(*impl));
  impl->flushedLSN_lock   = initlock();
  impl->globalOffset_lock = initlock();
  impl->globalOffset = 0;
  impl->nextAvailableLSN = 0;
  if(stasis_log_in_memory_max_entries == 0) {
    impl->bufferLen =4096 * 1024;
    impl->maxLen = 0;
  } else {
    impl->bufferLen = stasis_log_in_memory_max_entries;
    impl->maxLen = impl->bufferLen;
  }
  impl->buffer = malloc(impl->bufferLen * sizeof (LogEntry *));
  impl->trunc = 0;
  static stasis_log_t proto = {
    stasis_log_impl_in_memory_set_truncation,
    stasis_log_impl_in_memory_sizeof_internal_entry,
    stasis_log_impl_in_memory_write_entry,
    stasis_log_impl_in_memory_reserve_entry,
    stasis_log_impl_in_memory_entry_done,
    stasis_log_impl_in_memory_read_entry,
    stasis_log_impl_in_memory_read_entry_done,
    stasis_log_impl_in_memory_next_entry,
    stasis_log_impl_in_memory_first_unstable_lsn,
    stasis_log_impl_in_memory_first_pending_lsn,
    stasis_log_impl_in_memory_next_available_lsn,
    stasis_log_impl_in_memory_force_tail,
    stasis_log_impl_in_memory_truncate,
    stasis_log_impl_in_memory_truncation_point,
    stasis_log_impl_in_memory_close,
    stasis_log_impl_in_memory_is_durable
  };
  stasis_log_t* log = malloc(sizeof(*log));
  memcpy(log,&proto, sizeof(proto));
  log->impl = impl;
  return log;
}
Esempio n. 25
0
void
initlog(void)
{
  if (sizeof(struct logheader) >= BSIZE)
    panic("initlog: too big logheader");

  struct superblock sb;
  initlock(&log.lock, "log");
  readsb(ROOTDEV, &sb);
  log.start = sb.size - sb.nlog;
  log.size = sb.nlog;
  log.dev = ROOTDEV;
  recover_from_log();
}
Esempio n. 26
0
void
pinit(void)
{
  initlock(&ptable.lock, "ptable");
  
  if ((q = (queue*)kalloc()) != 0) {
    q->id         = 1;
    q->nr_msg     = 0;
    q->first_msg  = 0;
    q->last_msg   = 0;

    cprintf("\n\nMESSAGE QUEUE %d CREATED!\n\n", q->id);
  } 
}
Esempio n. 27
0
void
initlog(int dev)
{
  if (sizeof(struct logheader) >= BSIZE)
    panic("initlog: too big logheader");

  struct superblock sb;
  initlock(&log.lock, "log");
  readsb(dev, &sb);
  log.start = sb.logstart;
  log.size = sb.nlog;
  log.dev = dev;
  recover_from_log();
}
Esempio n. 28
0
File: kalloc.c Progetto: sihai/myos
// Initialize free list of physical pages.
// This code cheats by just considering one megabyte of
// pages after _end.  Real systems would determine the
// amount of memory available in the system and use it all.
void
kinit(void)
{
  extern int end;
  uint mem;
  char *start;

  initlock(&kalloc_lock, "kalloc");
  start = (char*) &end;
  start = (char*) (((uint)start + PAGE) & ~(PAGE-1));
  mem = 256; // assume computer has 256 pages of RAM
  cprintf("mem = %d\n", mem * PAGE);
  kfree(start, mem * PAGE);
}
Esempio n. 29
0
sys_mbox_t sys_mbox_new(void)
{
    sys_mbox_t mbox = (sys_mbox_t)kmalloc(sizeof(struct mbox));
    if (!mbox)
        return SYS_MBOX_NULL;
    initlock(&mbox->lock, "mbox");
    mbox->free = (sem_t *)kmalloc(sem_size());
    mbox->queued = (sem_t *)kmalloc(sem_size());
    sem_init(mbox->free, NSLOTS);
    sem_init(mbox->queued, 0);
    mbox->count = 0;
    mbox->head = -1;
    mbox->next = 0;
    return mbox;
};
int
PrivacyChecker::initializeGMain(void)
{
	std::unique_lock<std::mutex> initlock(m_initializeMutex);

	TryReturn(!m_isInitialized, PRIV_FLTR_ERROR_SUCCESS, , "Already Initalized");

	m_pHandlerGMainContext = g_main_context_new();
	TryReturn(m_pHandlerGMainContext != NULL, PRIV_FLTR_ERROR_SYSTEM_ERROR, ,"cannot create m_pHandlerGMainContext");

	m_pLoop = g_main_loop_new(m_pHandlerGMainContext, FALSE);
	TryReturn(m_pLoop != NULL, PRIV_FLTR_ERROR_SYSTEM_ERROR, ,"cannot create m_pLoop");

	std::unique_lock<std::mutex> lock(m_dbusMutex);
	int res = pthread_create(&m_signalThread, NULL, &runSignalListenerThread, NULL);
	TryReturn(res >= 0, PRIV_FLTR_ERROR_SYSTEM_ERROR, errno = res;, "Failed to create listener thread :%s", strerror(res));