简体   繁体   English

用户空间和内核空间进程中的信号处理程序集

[英]set of signal handlers in user space and kernel space processes

I am a newbie to linux.. 我是linux的新手。

Do the "user space processes" and "kernel space processes(kernel threads)" share the same set of signal. “用户空间进程”和“内核空间进程(内核线程)”是否共享同一组信号。 handlers.Just wanted to how kernel sends signals differently depending on the region(user space or kernel space)where the process is running? 只是想知道内核如何根据进程运行的区域(用户空间或内核空间)不同地发送信号?

I think there may be some confusion here. 我认为这里可能有些混乱。 When people say "kernel thread" in the context of UNIX, they generally just mean "thread," not "kernel space process." 当人们在UNIX上下文中说“内核线程”时,通常只表示“线程”,而不是“内核空间进程”。 In the past there were two approaches to threading: libraries that implemented the concept without any assistance from the kernel, which is called user threads; 过去有两种线程化方法:在无需任何内核帮助的情况下实现该概念的库(称为用户线程)。 and those that mainly just wrap system calls provided by the kernel specifically for multithreading, called kernel threads. 以及那些只包装由内核专门为多线程提供的系统调用的内核线程。 These days mostly people use kernel threads, especially because the POSIX threads standard has been part of the Linux kernel since 2.6. 如今,大多数人使用内核线程,尤其是因为POSIX线程标准从2.6开始就已成为Linux内核的一部分。

To answer your question, signals are always addressed to a PID (well, unless you use pthread_kill for inter-thread signaling). 为了回答您的问题,信号始终被寻址到PID(嗯,除非您将pthread_kill用于线程间信号传输)。 With POSIX threads, all the threads of a process share a single PID. 使用POSIX线程,进程的所有线程共享一个PID。 But only one thread can actually be interrupted. 但是实际上只有一个线程可以被中断。 So each thread has as part of its thread-local storage a signal mask. 因此,每个线程在其线程本地存储中都有一个信号掩码。 In practice what you are supposed to do is use pthread_sigmask to say explicitly which threads handle which signals. 实际上,您应该做的是使用pthread_sigmask明确指出哪些线程处理哪些信号。 In Linux the root thread is the default. 在Linux中,根线程是默认线程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 std :: threads在用户或内核空间中管理? - std::threads are managed in user or kernel space? 内核模块定期调用用户空间程序 - Kernel module periodically calling user space program 跨内核和用户空间的Linux时序 - Linux Timing across Kernel & User Space ptrace 访问用户空间还是内核空间? - Does ptrace access user or kernel space? macOS 上的内核与用户空间音频设备驱动程序 - kernel vs user-space audio device driver on macOS 从套接字读取,而没有从内核空间到用户空间的关联memcpy - Read from a socket without the associated memcpy from kernel space to user space pthread_spinlock 是否会导致从用户空间切换到内核空间 - Does pthread_spinlock cause switch from user space to kernel space 为什么共享内存(在ipc中)不需要上下文切换? 它是从内核空间映射到用户空间的内存吗? - Why does a shared memory (in ipc) not require context switching ? Is it a memory from kernel space that gets mapped to user space? 在Windows内核驱动程序中与用户空间共享来自内核空间的多个“ 4Go-PAGE_SIZE”缓冲区 - Sharing more than “4Go - PAGE_SIZE” buffer from kernel space with user space in a windows kernel driver 在内核空间中调用NtQuerySystemInformation - Call NtQuerySystemInformation in kernel-space
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM