本文整理汇总了C++中do_exit函数的典型用法代码示例。如果您正苦于以下问题:C++ do_exit函数的具体用法?C++ do_exit怎么用?C++ do_exit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了do_exit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_child_1
/*
* do_child_1()
*/
void
do_child_1(void)
{
int kid_count, fork_kid_pid[MAXKIDS];
int ret_val;
int i, j, k, found;
int group1, group2;
int wait_kid_pid[MAXKIDS], status;
setup_sigint();
group1 = getpgrp();
for (kid_count = 0; kid_count < MAXKIDS; kid_count++) {
if (kid_count == (MAXKIDS / 2)) {
group2 = setpgrp();
}
intintr = 0;
ret_val = FORK_OR_VFORK();
if (ret_val == 0) { /* child */
#ifdef UCLINUX
if (self_exec(argv0, "n", 2) < 0) {
tst_resm(TFAIL, "Fork kid %d failed. "
"errno = %d", kid_count,
errno);
exit(ret_val);
}
#else
do_exit();
#endif
/*NOTREACHED*/
} else if (ret_val < 0) {
tst_resm(TFAIL, "Fork kid %d failed. "
"errno = %d", kid_count,
errno);
exit(ret_val);
}
/* parent */
fork_kid_pid[kid_count] = ret_val;
}
#ifdef UCLINUX
/* Give the kids a chance to setup SIGINT again, since this is
* cleared by exec().
*/
sleep(3);
#endif
/* Now send all the kids a SIGINT to tell them to
* proceed
*/
for (i = 0; i < MAXKIDS; i++) {
if (kill(fork_kid_pid[i], SIGINT) < 0) {
tst_resm(TFAIL, "Kill of child %d "
"failed, errno = %d", i, errno);
exit(-1);
}
}
/*
* Wait till all kids have terminated. Stash away their
* pid's in an array.
*/
kid_count = 0;
errno = 0;
while (((ret_val = waitpid(-1, &status, 0)) != -1) ||
(errno == EINTR)) {
if (ret_val == -1) {
continue;
}
if (!WIFEXITED(status)) {
tst_resm(TFAIL, "Child %d did not exit "
"normally", ret_val);
flag = FAILED;
printf("status: %d\n", status);
} else {
if (WEXITSTATUS(status) != 3) {
tst_resm(TFAIL, "Child %d"
"exited with wrong "
"status", ret_val);
tst_resm(TFAIL, "Expected 3 "
"got %d ",
WEXITSTATUS(status));
flag = FAILED;
}
}
wait_kid_pid[kid_count++] = ret_val;
}
/*
* Check that for every entry in the fork_kid_pid array,
* there is a matching pid in the wait_kid_pid array. If
* not, it's an error.
*/
for (i = 0; i < kid_count; i++) {
found = 0;
//.........这里部分代码省略.........
示例2: kernel_thread_helper
/*
* Create a kernel thread
*/
ATTRIB_NORET void kernel_thread_helper(void *arg, int (*fn)(void *))
{
do_exit(fn(arg));
}
示例3: new_pt_frame
/*
* Make pt_pfn a new 'level' page table frame and hook it into the page
* table at offset in previous level MFN (pref_l_mfn). pt_pfn is a guest
* PFN.
*/
static void new_pt_frame(unsigned long *pt_pfn, unsigned long prev_l_mfn,
unsigned long offset, unsigned long level)
{
pgentry_t *tab = (pgentry_t *)start_info.pt_base;
unsigned long pt_page = (unsigned long)pfn_to_virt(*pt_pfn);
pgentry_t prot_e, prot_t;
mmu_update_t mmu_updates[1];
int rc;
prot_e = prot_t = 0;
DEBUG("Allocating new L%d pt frame for pfn=%lx, "
"prev_l_mfn=%lx, offset=%lx",
level, *pt_pfn, prev_l_mfn, offset);
/* We need to clear the page, otherwise we might fail to map it
as a page table page */
memset((void*) pt_page, 0, PAGE_SIZE);
switch ( level )
{
case L1_FRAME:
prot_e = L1_PROT;
prot_t = L2_PROT;
break;
case L2_FRAME:
prot_e = L2_PROT;
prot_t = L3_PROT;
break;
case L3_FRAME:
prot_e = L3_PROT;
prot_t = L4_PROT;
break;
default:
printk("new_pt_frame() called with invalid level number %d\n", level);
do_exit();
break;
}
/* Make PFN a page table page */
tab = pte_to_virt(tab[l4_table_offset(pt_page)]);
tab = pte_to_virt(tab[l3_table_offset(pt_page)]);
mmu_updates[0].ptr = (tab[l2_table_offset(pt_page)] & PAGE_MASK) +
sizeof(pgentry_t) * l1_table_offset(pt_page);
mmu_updates[0].val = (pgentry_t)pfn_to_mfn(*pt_pfn) << PAGE_SHIFT |
(prot_e & ~_PAGE_RW);
if ( (rc = HYPERVISOR_mmu_update(mmu_updates, 1, NULL, DOMID_SELF)) < 0 )
{
printk("ERROR: PTE for new page table page could not be updated\n");
printk(" mmu_update failed with rc=%d\n", rc);
do_exit();
}
/* Hook the new page table page into the hierarchy */
mmu_updates[0].ptr =
((pgentry_t)prev_l_mfn << PAGE_SHIFT) + sizeof(pgentry_t) * offset;
mmu_updates[0].val = (pgentry_t)pfn_to_mfn(*pt_pfn) << PAGE_SHIFT | prot_t;
if ( (rc = HYPERVISOR_mmu_update(mmu_updates, 1, NULL, DOMID_SELF)) < 0 )
{
printk("ERROR: mmu_update failed with rc=%d\n", rc);
do_exit();
}
*pt_pfn += 1;
}
示例4: syscall_dispatch
static int syscall_dispatch(uint32_t sysnum, uint32_t args, regs_t *regs)
{
switch (sysnum) {
case SYS_waitpid:
return sys_waitpid((waitpid_args_t *)args);
case SYS_exit:
do_exit((int)args);
panic("exit failed!\n");
return 0;
case SYS_thr_exit:
kthread_exit((void *)args);
panic("thr_exit failed!\n");
return 0;
case SYS_thr_yield:
sched_make_runnable(curthr);
sched_switch();
return 0;
case SYS_fork:
return sys_fork(regs);
case SYS_getpid:
return curproc->p_pid;
case SYS_sync:
sys_sync();
return 0;
#ifdef __MOUNTING__
case SYS_mount:
return sys_mount((mount_args_t *) args);
case SYS_umount:
return sys_umount((argstr_t *) args);
#endif
case SYS_mmap:
return (int) sys_mmap((mmap_args_t *) args);
case SYS_munmap:
return sys_munmap((munmap_args_t *) args);
case SYS_open:
return sys_open((open_args_t *) args);
case SYS_close:
return sys_close((int)args);
case SYS_read:
return sys_read((read_args_t *)args);
case SYS_write:
return sys_write((write_args_t *)args);
case SYS_dup:
return sys_dup((int)args);
case SYS_dup2:
return sys_dup2((dup2_args_t *)args);
case SYS_mkdir:
return sys_mkdir((mkdir_args_t *)args);
case SYS_rmdir:
return sys_rmdir((argstr_t *)args);
case SYS_unlink:
return sys_unlink((argstr_t *)args);
case SYS_link:
return sys_link((link_args_t *)args);
case SYS_rename:
return sys_rename((rename_args_t *)args);
case SYS_chdir:
return sys_chdir((argstr_t *)args);
case SYS_getdents:
return sys_getdents((getdents_args_t *)args);
case SYS_brk:
return (int) sys_brk((void *)args);
case SYS_lseek:
return sys_lseek((lseek_args_t *)args);
case SYS_halt:
sys_halt();
return -1;
case SYS_set_errno:
curthr->kt_errno = (int)args;
return 0;
case SYS_errno:
return curthr->kt_errno;
//.........这里部分代码省略.........
示例5: trap_dispatch
static void
trap_dispatch(struct trapframe *tf) {
char c;
int ret=0;
switch (tf->tf_trapno) {
case T_PGFLT: //page fault
if ((ret = pgfault_handler(tf)) != 0) {
print_trapframe(tf);
if (current == NULL) {
panic("handle pgfault failed. ret=%d\n", ret);
}
else {
if (trap_in_kernel(tf)) {
panic("handle pgfault failed in kernel mode. ret=%d\n", ret);
}
cprintf("killed by kernel.\n");
cprintf("current %s.\n",current->name);
panic("handle user mode pgfault failed. ret=%d\n", ret);
do_exit(-E_KILLED);
}
}
break;
case T_SYSCALL:
syscall();
break;
case IRQ_OFFSET + IRQ_TIMER:
#if 0
LAB3 : If some page replacement algorithm(such as CLOCK PRA) need tick to change the priority of pages,
then you can add code here.
#endif
/* LAB1 YOUR CODE : STEP 3 */
/* handle the timer interrupt */
/* (1) After a timer interrupt, you should record this event using a global variable (increase it), such as ticks in kern/driver/clock.c
* (2) Every TICK_NUM cycle, you can print some info using a funciton, such as print_ticks().
* (3) Too Simple? Yes, I think so!
*/
/* LAB5 YOUR CODE */
/* you should upate you lab1 code (just add ONE or TWO lines of code):
* Every TICK_NUM cycle, you should set current process's current->need_resched = 1
*/
break;
case IRQ_OFFSET + IRQ_COM1:
c = cons_getc();
cprintf("serial [%03d] %c\n", c, c);
break;
case IRQ_OFFSET + IRQ_KBD:
c = cons_getc();
cprintf("kbd [%03d] %c\n", c, c);
break;
//LAB1 CHALLENGE 1 : YOUR CODE you should modify below codes.
case T_SWITCH_TOU:
case T_SWITCH_TOK:
panic("T_SWITCH_** ??\n");
break;
case IRQ_OFFSET + IRQ_IDE1:
case IRQ_OFFSET + IRQ_IDE2:
/* do nothing */
break;
default:
print_trapframe(tf);
if (current != NULL) {
cprintf("unhandled trap.\n");
do_exit(-E_KILLED);
}
// in kernel, it must be a mistake
panic("unexpected trap in kernel.\n");
}
}
示例6: sys_exit
static uint32_t
sys_exit(uint32_t arg[]) {
int error_code = (int)arg[0];
return do_exit(error_code);
}
示例7: trap_dispatch
static void
trap_dispatch(struct trapframe *tf) {
char c;
int ret=0;
switch (tf->tf_trapno) {
case T_PGFLT: //page fault
if ((ret = pgfault_handler(tf)) != 0) {
print_trapframe(tf);
if (current == NULL) {
panic("handle pgfault failed. ret=%d\n", ret);
}
else {
if (trap_in_kernel(tf)) {
panic("handle pgfault failed in kernel mode. ret=%d\n", ret);
}
cprintf("killed by kernel.\n");
panic("handle user mode pgfault failed. ret=%d\n", ret);
do_exit(-E_KILLED);
}
}
break;
case T_SYSCALL:
syscall();
break;
case IRQ_OFFSET + IRQ_TIMER:
//LAB3_X 2013011509
//Call swap manager timer handler here
if (check_mm_struct != NULL) {
assert(swap_tick_event(check_mm_struct) == 0);
}
ticks++;
run_timer_list();
#if 0
LAB3 : If some page replacement algorithm(such as CLOCK PRA) need tick to change the priority of pages,
then you can add code here.
#endif
/* LAB1 YOUR CODE : STEP 3 */
/* handle the timer interrupt */
/* (1) After a timer interrupt, you should record this event using a global variable (increase it), such as ticks in kern/driver/clock.c
* (2) Every TICK_NUM cycle, you can print some info using a funciton, such as print_ticks().
* (3) Too Simple? Yes, I think so!
*/
/* you should upate you lab1 code (just add ONE or TWO lines of code):
* Every TICK_NUM cycle, you should set current process's current->need_resched = 1
*/
/* LAB6 YOUR CODE */
/* you should upate you lab5 code
* IMPORTANT FUNCTIONS:
* sched_class_proc_tick
*/
/* LAB7 YOUR CODE */
/* you should upate you lab6 code
* IMPORTANT FUNCTIONS:
* run_timer_list
*/
break;
case IRQ_OFFSET + IRQ_COM1:
case IRQ_OFFSET + IRQ_KBD:
// There are user level shell in LAB8, so we need change COM/KBD interrupt processing.
c = cons_getc();
{
extern void dev_stdin_write(char c);
dev_stdin_write(c);
}
break;
//LAB1 CHALLENGE 1 : YOUR CODE you should modify below codes.
case T_SWITCH_TOU:
case T_SWITCH_TOK:
panic("T_SWITCH_** ??\n");
break;
case IRQ_OFFSET + IRQ_IDE1:
case IRQ_OFFSET + IRQ_IDE2:
/* do nothing */
break;
default:
print_trapframe(tf);
if (current != NULL) {
cprintf("unhandled trap.\n");
do_exit(-E_KILLED);
}
// in kernel, it must be a mistake
panic("unexpected trap in kernel.\n");
}
}
示例8: task_mm
/**
* <Ring 1> The main loop of TASK MM.
*
*****************************************************************************/
PUBLIC void task_mm()
{
init_mm();
while (1) {
send_recv(RECEIVE, ANY, &mm_msg);
int src = mm_msg.source;
int reply = 1;
int msgtype = mm_msg.type;
switch (msgtype) {
case FORK:
mm_msg.RETVAL = do_fork();
break;
case EXIT:
do_exit(mm_msg.STATUS);
reply = 0;
break;
case EXEC:
mm_msg.RETVAL = do_exec();
break;
case WAIT:
do_wait();
reply = 0;
break;
case KILL:
mm_msg.RETVAL = do_kill();
break;
case RAISE:
mm_msg.RETVAL = do_raise();
break;
case BRK:
mm_msg.RETVAL = do_brk();
break;
case ACCT:
mm_msg.RETVAL = do_acct();
break;
case GETUID:
mm_msg.RETVAL = do_getuid();
break;
case SETUID:
mm_msg.RETVAL = do_setuid();
break;
case GETGID:
mm_msg.RETVAL = do_getgid();
break;
case SETGID:
mm_msg.RETVAL = do_setgid();
break;
case GETEUID:
mm_msg.RETVAL = do_geteuid();
break;
case GETEGID:
mm_msg.RETVAL = do_getegid();
break;
case SIGACTION:
mm_msg.RETVAL = do_sigaction();
break;
case ALARM:
mm_msg.RETVAL = do_alarm();
break;
default:
dump_msg("MM::unknown msg", &mm_msg);
assert(0);
break;
}
if (reply) {
mm_msg.type = SYSCALL_RET;
send_recv(SEND, src, &mm_msg);
}
}
}
示例9: kernel_thread_helper
/*
* This is the mechanism for creating a new kernel thread.
*
* NOTE! Only a kernel-only process(ie the swapper or direct descendants
* who haven't done an "execve()") should use this: it will work within
* a system call from a "real" process, but the process memory space will
* not be free'd until both the parent and the child have exited.
*/
static void kernel_thread_helper(void *nouse, int (*fn)(void *), void *arg)
{
fn(arg);
do_exit(-1);
}
示例10: bad_stack
/*
* If we ever come here the user sp is bad. Zap the process right away.
* Due to the bad stack signaling wouldn't work.
*/
asmlinkage void bad_stack(void)
{
do_exit(SIGSEGV);
}
示例11: __do_deliver_interrupt
//.........这里部分代码省略.........
rc = put_guest_u32(vcpu, __LC_EXT_PARAMS, inti->ext.ext_params);
if (rc == -EFAULT)
exception = 1;
break;
case KVM_S390_INT_VIRTIO:
VCPU_EVENT(vcpu, 4, "interrupt: virtio parm:%x,parm64:%llx",
inti->ext.ext_params, inti->ext.ext_params2);
vcpu->stat.deliver_virtio_interrupt++;
rc = put_guest_u16(vcpu, __LC_EXT_INT_CODE, 0x2603);
if (rc == -EFAULT)
exception = 1;
rc = put_guest_u16(vcpu, __LC_CPU_ADDRESS, 0x0d00);
if (rc == -EFAULT)
exception = 1;
rc = copy_to_guest(vcpu, __LC_EXT_OLD_PSW,
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
if (rc == -EFAULT)
exception = 1;
rc = copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw,
__LC_EXT_NEW_PSW, sizeof(psw_t));
if (rc == -EFAULT)
exception = 1;
rc = put_guest_u32(vcpu, __LC_EXT_PARAMS, inti->ext.ext_params);
if (rc == -EFAULT)
exception = 1;
rc = put_guest_u64(vcpu, __LC_EXT_PARAMS2,
inti->ext.ext_params2);
if (rc == -EFAULT)
exception = 1;
break;
case KVM_S390_SIGP_STOP:
VCPU_EVENT(vcpu, 4, "%s", "interrupt: cpu stop");
vcpu->stat.deliver_stop_signal++;
__set_intercept_indicator(vcpu, inti);
break;
case KVM_S390_SIGP_SET_PREFIX:
VCPU_EVENT(vcpu, 4, "interrupt: set prefix to %x",
inti->prefix.address);
vcpu->stat.deliver_prefix_signal++;
vcpu->arch.sie_block->prefix = inti->prefix.address;
vcpu->arch.sie_block->ihcpu = 0xffff;
break;
case KVM_S390_RESTART:
VCPU_EVENT(vcpu, 4, "%s", "interrupt: cpu restart");
vcpu->stat.deliver_restart_signal++;
rc = copy_to_guest(vcpu, offsetof(struct _lowcore,
restart_old_psw), &vcpu->arch.sie_block->gpsw, sizeof(psw_t));
if (rc == -EFAULT)
exception = 1;
rc = copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw,
offsetof(struct _lowcore, restart_psw), sizeof(psw_t));
if (rc == -EFAULT)
exception = 1;
break;
case KVM_S390_PROGRAM_INT:
VCPU_EVENT(vcpu, 4, "interrupt: pgm check code:%x, ilc:%x",
inti->pgm.code,
table[vcpu->arch.sie_block->ipa >> 14]);
vcpu->stat.deliver_program_int++;
rc = put_guest_u16(vcpu, __LC_PGM_INT_CODE, inti->pgm.code);
if (rc == -EFAULT)
exception = 1;
rc = put_guest_u16(vcpu, __LC_PGM_ILC,
table[vcpu->arch.sie_block->ipa >> 14]);
if (rc == -EFAULT)
exception = 1;
rc = copy_to_guest(vcpu, __LC_PGM_OLD_PSW,
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
if (rc == -EFAULT)
exception = 1;
rc = copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw,
__LC_PGM_NEW_PSW, sizeof(psw_t));
if (rc == -EFAULT)
exception = 1;
break;
default:
BUG();
}
if (exception) {
printk("kvm: The guest lowcore is not mapped during interrupt "
"delivery, killing userspace\n");
do_exit(SIGKILL);
}
}
示例12: do_child_2_uclinux
/*
* do_child_2_uclinux()
* sets up sigint handler again, then calls the normal child 2 function
*/
void
do_child_2_uclinux(void)
{
setup_sigint();
do_exit();
}
示例13: do_exception
/*
* This routine handles page faults. It determines the address,
* and the problem, and then passes it off to one of the appropriate
* routines.
*
* error_code:
* 04 Protection -> Write-Protection (suprression)
* 10 Segment translation -> Not present (nullification)
* 11 Page translation -> Not present (nullification)
* 3b Region third trans. -> Not present (nullification)
*/
extern inline void
do_exception(struct pt_regs *regs, unsigned long error_code, int is_protection)
{
struct task_struct *tsk;
struct mm_struct *mm;
struct vm_area_struct * vma;
unsigned long address;
int user_address;
const struct exception_table_entry *fixup;
int si_code = SEGV_MAPERR;
tsk = current;
mm = tsk->mm;
/*
* Check for low-address protection. This needs to be treated
* as a special case because the translation exception code
* field is not guaranteed to contain valid data in this case.
*/
if (is_protection && !(S390_lowcore.trans_exc_code & 4)) {
/* Low-address protection hit in kernel mode means
NULL pointer write access in kernel mode. */
if (!(regs->psw.mask & PSW_MASK_PSTATE)) {
address = 0;
user_address = 0;
goto no_context;
}
/* Low-address protection hit in user mode 'cannot happen'. */
die ("Low-address protection", regs, error_code);
do_exit(SIGKILL);
}
/*
* get the failing address
* more specific the segment and page table portion of
* the address
*/
address = S390_lowcore.trans_exc_code & __FAIL_ADDR_MASK;
user_address = check_user_space(regs, error_code);
/*
* Verify that the fault happened in user space, that
* we are not in an interrupt and that there is a
* user context.
*/
if (user_address == 0 || in_interrupt() || !mm)
goto no_context;
/*
* When we get here, the fault happened in the current
* task's user address space, so we can switch on the
* interrupts again and then search the VMAs
*/
local_irq_enable();
down_read(&mm->mmap_sem);
vma = find_vma(mm, address);
if (!vma)
goto bad_area;
if (vma->vm_start <= address)
goto good_area;
if (!(vma->vm_flags & VM_GROWSDOWN))
goto bad_area;
if (expand_stack(vma, address))
goto bad_area;
/*
* Ok, we have a good vm_area for this memory access, so
* we can handle it..
*/
good_area:
si_code = SEGV_ACCERR;
if (!is_protection) {
/* page not present, check vm flags */
if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
goto bad_area;
} else {
if (!(vma->vm_flags & VM_WRITE))
goto bad_area;
}
survive:
/*
* If for any reason at all we couldn't handle the fault,
* make sure we exit gracefully rather than endlessly redo
* the fault.
*/
//.........这里部分代码省略.........
示例14: sys_exit
//// 系统调用exit()。终止进程。
int sys_exit (int error_code)
{
return do_exit ((error_code & 0xff) << 8);
}
示例15: SYSCALL_DEFINE1
SYSCALL_DEFINE1(exit, int, error_code) {
do_exit((error_code&0xff) << 8);
return SYSCALL_RETURN(0);
}