interrupted-exception

Why linux kernel use trap gate to handle divide_error exception?

只愿长相守 提交于 2020-01-27 20:54:46
问题 In kernel 2.6.11.5, divide zero exception handler is set up as: set_trap_gate(0,&divide_error); According to "Understanding The Linux Kernel", Intel trap gate cannot be accessed by a User Mode process. But it's quite possible that a user mode process also generate a divide_error . So why Linux implement it in this way? [Edit] I think that the question is still open, since set_trap_gate() sets DPL value of IDT entry to 0, which means only CPL=0 (read kernel) code can execute it, so it's

Why linux kernel use trap gate to handle divide_error exception?

会有一股神秘感。 提交于 2020-01-27 20:53:58
问题 In kernel 2.6.11.5, divide zero exception handler is set up as: set_trap_gate(0,&divide_error); According to "Understanding The Linux Kernel", Intel trap gate cannot be accessed by a User Mode process. But it's quite possible that a user mode process also generate a divide_error . So why Linux implement it in this way? [Edit] I think that the question is still open, since set_trap_gate() sets DPL value of IDT entry to 0, which means only CPL=0 (read kernel) code can execute it, so it's

Why linux kernel use trap gate to handle divide_error exception?

这一生的挚爱 提交于 2020-01-27 20:53:24
问题 In kernel 2.6.11.5, divide zero exception handler is set up as: set_trap_gate(0,&divide_error); According to "Understanding The Linux Kernel", Intel trap gate cannot be accessed by a User Mode process. But it's quite possible that a user mode process also generate a divide_error . So why Linux implement it in this way? [Edit] I think that the question is still open, since set_trap_gate() sets DPL value of IDT entry to 0, which means only CPL=0 (read kernel) code can execute it, so it's

Propagate system call interruptions in threads

感情迁移 提交于 2020-01-06 20:05:47
问题 I'm running two python threads ( import threading ). Both of them are blocked on a open() call; in fact they try to open named pipes in order to write in them, so it's a normal behaviour to block until somebody try to read from the named pipe. In short, it looks like: import threading def f(): open('pipe2', 'r') if __name__ == '__main__': t = threading.Thread(target=f) t.start() open('pipe1', 'r') When I type a ^C, the open() in the main thread is interrupted (raises IOError with errno == 4).

Interrupting an assembly instruction while it is operating

﹥>﹥吖頭↗ 提交于 2020-01-03 16:54:10
问题 When an interrupt comes to CPU, it is handled by saving current address location prior jumping into the handler if it is acknowledged. Otherwise it is ignored. I wonder whether an assembly instruction call is interrupted. For example, mvi a, 03h ; put 3 value into acc. in 8080 assembly Can be the one line instruction interrupted? Or if not, it is atomic?? Is there always a guarantee that "one line assembly instruction" is always atomic?? What if there is no "lock" keyword i.e. in 8080

epoll_wait fails due to EINTR, how to remedy this?

Deadly 提交于 2020-01-02 08:48:18
问题 My epoll_wait fails due to EINTR. My gdb trace shows this: enter code here 221 in ../nptl/sysdeps/pthread/createthread.c (gdb) 224 in ../nptl/sysdeps/pthread/createthread.c (gdb) [New Thread 0x40988490 (LWP 3589)] 227 in ../nptl/sysdeps/pthread/createthread.c (gdb) epoll_wait error in start timer: Measurement will befor entire duration of execution epoll_wait: Interrupted system call [Thread 0x40988490 (LWP 3589) exited] This string "epoll_wait error in start timer: Measurement will befor

How to handle dispose in RxJava without InterruptedException

。_饼干妹妹 提交于 2020-01-01 17:07:09
问题 In the below code snipped when dispose() is called, then the emitter thread is interrupted ( InterruptedException is thrown out of sleep method). Observable<Integer> obs = Observable.create(emitter -> { for (int i = 0; i < 10; i++) { if (emitter.isDisposed()) { System.out.println("> exiting."); emitter.onComplete(); return; } emitter.onNext(i); System.out.println("> calculation = " + i); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } emitter.onComplete()

Why would you catch InterruptedException to call Thread.currentThread.interrupt()?

半腔热情 提交于 2019-12-29 04:20:46
问题 In Effective Java (page 275), there is this code segment: ... for (int i = 0; i < concurrency; i++) { executor.execute(new Runnable() { public void run() { ready.countDown(); try { start.await(); action.run(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { done.countDown(); } } } ... What's the use of catching the interrupted exception just to re-raise it? Why not just let it fly? 回答1: The simple answer is that InterruptedException is a checked exception

Extracting a process's exit code in the case of ThreadInterrupted

人盡茶涼 提交于 2019-12-23 12:35:08
问题 I have just created a process through an exec() call and I am now using its .waitFor() method. I need to catch an InterruptedException but I am not sure what I should place in the catch code block. I would like to receive the exit code but I won't if the current thread is interrupted. What should I do to get the exit code out of the process if the thread is interrupted? Example: import java.io.IOException; public class Exectest { public static void main(String args[]){ int exitval; try {

LinkedBlockingQueue thowing InterruptedException

旧巷老猫 提交于 2019-12-20 07:22:32
问题 I have this piece of code. A LinkedBlockingQueue should only throw an Exception if interrupted while waiting to add to the queue. But this queue is unbounded so it should add asap. Why does my shutdown methode throw an InterruptedException ? private final LinkedBlockingQueue<Message> messages= new LinkedBlockingQueue<Message>(); public void run(){ LinkedList<Message> messages = new LinkedList<Message>(); while (true){ try{ messages.clear(); messages.add(this.messages.take()); this.messages