示例#1
0
/* ilk process i (task0, kernel task) olusturur */
void init_kernel_task(struct dirent* root) {
	int r;

	ASSERT_int_disable();

	task_curr = &task0;

	task_curr->init();
	task_curr->shared_mem_list.init();
	task_curr->priority = 3;
	fs_task_init(task_curr, root);

	/* task icin kernel stack alani olustur */
	r = task_curr->pgdir.segment_alloc(MMAP_KERNEL_STACK_BASE,
									   MMAP_KERNEL_STACK_SIZE,
									   PTE_P | PTE_W);
	ASSERT( r == 0 );
	move_stack((uint32_t)&__boot_stack + (0x4000-MMAP_KERNEL_STACK_SIZE),
			   va2kaddr(MMAP_KERNEL_STACK_BASE), MMAP_KERNEL_STACK_SIZE);

	/* process id ata ve runnable listesine ekle */
	set_task_id(task_curr);
	add_to_runnable_list(task_curr);

	print_info(">> task %d created\n", task_curr->id);
}
DebuggerEvent::DebuggerEvent(jbyte kind, int thread_id,
                             int clazz_id, jlong method_id,
                             jlong offset) :
  _offset(offset),
  _thread_id(thread_id),
  _clazz_id(clazz_id),
  _method_id(method_id),
  _event_kind(kind)
{
#if ENABLE_ISOLATES
  set_task_id(Thread::current()->task_id());
#endif
}
示例#3
0
int XmppTaskIq::ProcessStart() {

  set_task_id(GetClient()->NextId());

  txmpp::scoped_ptr<txmpp::XmlElement> privacy(
      MakeIq("get", txmpp::JID_EMPTY, task_id()));
  txmpp::XmlElement *query = new txmpp::XmlElement(txmpp::QN_PRIVACY_QUERY);
  privacy->AddElement(query);

  SendStanza(privacy.get());

  return STATE_RESPONSE;
}
示例#4
0
 void ComLog::init(const int task_id)
 {
     set_task_id(task_id, false); 
 }
示例#5
0
 // real
 void ComLog::init()
 {
     set_task_id(-1, true);
 }
示例#6
0
// TODO: fork kurallari duzenlenmeli (neler kopyalanacak, neler kopyalanmayacak?)
int do_fork() {
	CLOBBERED_REGISTERS_ALL();

	/* debug only */
	uint32_t mem_before_setup_vm = 0;
	uint32_t mem_before_copy_pages = 0;
	uint32_t mem_before_kernel_stack = 0;
	/* */
	int r;
	Task *t;
	uint32_t eip;
	int e = 0; // error (bad_fork_* icin)

	pushcli();
	// ASSERT_int_disable();

	t = (Task*)kmalloc(sizeof(Task));
	if (!t)
		goto bad_fork_task_alloc;

	memcpy(t, task_curr, sizeof(Task));
	t->init();
	t->parent = task_curr;
	t->state = Task::State_not_runnable;

	/* -- */
	mem_before_setup_vm = mem_free();
	r = task_setup_vm(t, &task_curr->pgdir);
	if (r < 0)
		goto bad_fork_setup_vm;

	/* user adres uzayini kopyala */
	mem_before_copy_pages = mem_free();
	r = t->pgdir.copy_pages(&task_curr->pgdir, MMAP_USER_BASE,
							MMAP_USER_SHARED_MEM_BASE);
	if (r < 0)
		goto bad_fork_copy_vm_user;
	/* shared memory kismini kopyalama, shm_fork fonksiyonu kopyalayacak */
	r = t->pgdir.copy_pages(&task_curr->pgdir, MMAP_USER_SHARED_MEM_TOP,
							MMAP_USER_TOP);
	if (r < 0)
		goto bad_fork_copy_vm_user;
	t->pgdir.count_program = task_curr->pgdir.count_program;
	t->pgdir.count_stack = task_curr->pgdir.count_stack;
	t->pgdir.start_brk = task_curr->pgdir.start_brk;
	t->pgdir.end_brk = task_curr->pgdir.end_brk;
	/* */

	/* ipc veriyapilari icin, ipc_fork */
	r = ipc_fork(t);
	if (r < 0)
		goto bad_fork_ipc;

	r = fs_fork(t);
	if (r < 0)
		goto bad_fork_fs;

	/* kernel stackini kopyala */
	mem_before_kernel_stack = mem_free();
	r = t->pgdir.copy_pages(&task_curr->pgdir, MMAP_KERNEL_STACK_BASE, MMAP_KERNEL_STACK_TOP);
	if (r < 0)
		goto bad_fork_copy_kernel_stack;

	/* burasi 2 kere calisiyor */
	eip = read_eip();
	if (eip == 1) /* child process'de popif yapilmamali */
		return 0;

	/* child prosesin register bilgileri */
	t->k_eip = eip;
	read_reg(%esp, t->k_esp);
	read_reg(%ebp, t->k_ebp);

	/* child prosesin baslangic zamani */
	t->time_start = jiffies;


	/* child listesine ekle */
	ASSERT( task_curr->childs.push_back(&t->childlist_node) );
	/* process id ata ve runnable listesine ekle */
	set_task_id(t);
	add_to_runnable_list(t);

	popif();

	return t->id;

bad_fork_copy_kernel_stack:
	if (e++ == 0)
		print_warning("!! bad_fork_copy_kernel_stack\n");
	task_free_kernel_stack(t);
	ASSERT(mem_free() == mem_before_kernel_stack);
bad_fork_fs:
	// TODO: --
bad_fork_ipc:
	// TODO: --
bad_fork_copy_vm_user:
	if (e++ == 0)
		print_warning("!! bad_fork_copy_vm_user\n");
	task_free_vm_user(t);
	ASSERT(mem_free() == mem_before_copy_pages);
bad_fork_setup_vm:
	if (e++ == 0)
		print_warning("!! bad_fork_setup_vm\n");
	task_delete_vm(t);
	ASSERT(mem_free() == mem_before_setup_vm);
	kfree(t);
	t = NULL;
bad_fork_task_alloc:
	if (e++ == 0)
		print_warning("!! bad_fork_task_alloc\n");
	ASSERT(t == NULL);

	popif();
	return -1;
}