interrupt

interrupt() doesn't work

为君一笑 提交于 2019-11-30 03:31:00
问题 I am trying to terminate the thread in the following code: public synchronized void run() { try { while (!Thread.currentThread().isInterrupted()) { this.scan(); this.distribute(); this.wait(); } } catch (InterruptedException e) {} } public void cancel() { this.interrupt(); } But the thread won't terminate. I used the debugger and found out that after the command this.interrupt() , the thread doesn't get interrupted (I put a watch on the expression this.isInterrupted() and it stays false ).

How does a CPU idle (or run below 100%)?

て烟熏妆下的殇ゞ 提交于 2019-11-30 03:14:43
问题 I first learned about how computers work in terms of a primitive single stored program machine. Now I'm learning about multitasking operating systems, scheduling, context switching, etc. I think I have a fairly good grasp of it all, except for one thing. I have always thought of a CPU as something which is just charging forward non-stop. It always knows where to go next (program counter), and it goes to that instruction, etc, ad infinitum. Clearly this is not the case since my desktop

When an Thread.interrupt() is called on some thread, what happens? [duplicate]

这一生的挚爱 提交于 2019-11-30 02:45:23
问题 This question already has answers here : What does java.lang.Thread.interrupt() do? (9 answers) Closed 6 years ago . When an Thread.interrupt() is called on some thread, what happens to that thread? 回答1: The target thread is "interrupted". Mostly, a flag is set in that thread, which the thread can look at (with Thread.interrupted() ). If the target thread was currently blocked on some I/O or Object.wait() , then it is awakened with, respectively, an InterruptedIOException or an

Android usb host: asynchronous interrupt transfer

旧时模样 提交于 2019-11-30 02:13:24
I'm trying to connect a USB-Device ( build by myself ) to communicate with my development board ( ODROID-X ) Unfortunately, the examples are very little, as far as the asynchronous communication. I'd some problems with the interrupt driven data exchange - how to build the connection by using the asynchronous interrupt mode? In one direction, the transmission was possible ... but in both it doesn't work. Is there an example like this: send a ByteBuffer with endpoint_OUT get a message from device on endpoint_IN both in interrupt mode. Thanks a lot for your support. Hardy Neil Perhaps I am

Why disabling interrupts disables kernel preemption and how spin lock disables preemption

删除回忆录丶 提交于 2019-11-29 23:19:00
I am reading Linux Kernel Development recently, and I have a few questions related to disabling preemption. In the "Interrupt Control" section of chapter 7, it says: Moreover, disabling interrupts also disables kernel preemption. I also read from the book that kernel preemption can occur in the follow cases: When an interrupt handler exits, before returning to kernel-space. When kernel code becomes preemptible again. If a task in the kernel explicitly calls schedule() If a task in ther kernel blocks (which results in a call to schedule()) But I can't relate disabling interrupts with these

Which context are softirq and tasklet in?

荒凉一梦 提交于 2019-11-29 22:33:22
I know that there are process context and interrupt context but I don't understand when executing softirq or tasklet, which context is it run under. I have seen some people use the term "bottom-halves context", if there's such term, what's the difference comparing with the others. Another question to softirq and tasklet is that why sleep are not allowed during execution?? Can anyone help me identify these questions, thanks!! The softirq and tasklet are both kind of bottom-halves mechanism. Sleep is not allowed becuase they run under interrupt context not process context. If sleep is allowed,

Intel x86 vs x64 system call

≯℡__Kan透↙ 提交于 2019-11-29 20:11:52
I'm reading about the difference in assembly between x86 and x64. On x86, the system call number is placed in eax , then int 80h is executed to generate a software interrupt. But on x64, the system call number is placed in rax , then syscall is executed. I'm told that syscall is lighter and faster than generating a software interrupt. Why it is faster on x64 than x86, and can I make a system call on x64 using int 80h ? mikyra General part EDIT: Linux irrelevant parts removed While not totally wrong, narrowing down to int 0x80 and syscall oversimplifies the question as with sysenter there is at

How a thread should close itself in Java?

99封情书 提交于 2019-11-29 19:31:24
This is a short question. At some point my thread understand that it should suicide. What is the best way to do it: Thread.currentThread().interrupt(); return; By the way, why in the first case we need to use currentThread ? Is Thread does not refer to the current thread? If you want to terminate the thread , then just returning is fine. You do NOT need to call Thread.currentThread().interrupt() (it will not do anything bad though. It's just that you don't need to.) This is because interrupt() is basically used to notify the owner of the thread (well, not 100% accurate, but sort of). Because

The difference between Call Gate, Interrupt Gate, Trap Gate?

萝らか妹 提交于 2019-11-29 18:52:47
I am studying Intel Protected Mode. I found that Call Gate, Interrupt Gate, Trap Gate are almost the same. In fact, besides that Call Gate has the fields for parameter counter, and that these 3 gates have different type fields, they are identical in all other fields. As to their functions, they are all used to transfer code control into some procedure within some code segment. I am wondering, since these 3 gates all contain the information needed for the call across privilege boundaries. Why do we need 3 kinds of them? Isn't 1 just good enough? Thanks for your time and response. Update 1 A

Why two vector table addresses on ARM?

会有一股神秘感。 提交于 2019-11-29 18:45:50
问题 In ARM architecture there is one low vector address 0x0 and high vector address 0xFFFF0000 . I was wondering why two vector addresses might be needed ? In Intel microprocessors and microcontrollers there is one vector address. Is there any particular reason to have 2 vector addresses ? 回答1: Some microcontroller families have more than one to a number of different start addresses and/or they use the same address and switch in and out address decoding based on strap pins so that you can boot