Пример #1
0
SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
		 int __user *, parent_tidptr,
		 int __user *, child_tidptr,
		 unsigned long, tls)
#endif
{
	return _do_fork(clone_flags, newsp, 0, parent_tidptr, child_tidptr, tls);
}
Пример #2
0
/* For compatibility with architectures that call do_fork directly rather than
 * using the syscall entry points below. */
long do_fork(unsigned long clone_flags,
	      unsigned long stack_start,
	      unsigned long stack_size,
	      int __user *parent_tidptr,
	      int __user *child_tidptr)
{
	return _do_fork(clone_flags, stack_start, stack_size,
			parent_tidptr, child_tidptr, 0);
}
Пример #3
0
Файл: pm.c Проект: scbzyhx/os
void pm_thread() {
    static Msg m;
    PCB* pcb;
	while (true) {
		receive(ANY, &m);

		if (m.src == MSG_HARD_INTR) {
		    //do nothting
		} else if (m.type == NEW_PROCESS) {

            //TODO: only first file here, I should change it 
            uint32_t *file_name_buf = (uint32_t*)m.buf;

            size_t sz =  do_read(file_name_buf[0], buf, 0, FILE_SIZE);
            assert(sz == FILE_SIZE);
            pcb = create_process(buf);
			m.ret = pcb->pid;
			m.dest = m.src;
			m.src = PM;
			send(m.dest, &m);

		} else if (m.type == FORK) {
		    PCB *old = fetch_pcb(m.req_pid);
		    pid_t new_pid = _do_fork(old);
		    m.ret = new_pid;
		    m.dest = m.src;
		    m.src = PM;
		    send(m.dest,&m);
		    //for child process
		    m.ret = 0;
		    m.dest = new_pid; //send to new_pid
		    m.src = PM;
		    send(m.dest,&m);
        }
		else {
			assert(0);
		}
	}
}
Пример #4
0
/*
 * Create a kernel thread.
 */
pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
{
	return _do_fork(flags|CLONE_VM|CLONE_UNTRACED, (unsigned long)fn,
		(unsigned long)arg, NULL, NULL, 0);
}