interrupt

Keyboard interrupt in x86 protected mode causes processor error

点点圈 提交于 2019-12-02 01:35:20
I'm working on a simple kernel and I've been trying to implement a keyboard interrupt handler to get rid of port polling. I've been using QEMU in -kernel mode (to reduce compile time, because generating the iso using grub-mkrescue takes quite some time) and it worked just fine, but when I wanted to switch to -cdrom mode it suddenly started crashing. I had no idea why. Eventually I've realized that when it boots from an iso it also runs a GRUB bootloader before booting the kernel itself. I've figured out GRUB probably switches the processor into protected mode and that causes the problem . the

volatile vs memory barrier for interrupts

守給你的承諾、 提交于 2019-12-02 01:00:32
问题 Let x and y be variables that are shared between main code and interrupt code. My idea of volatile is that it is only and always needed for hardware variables and interrupt variables that are also used in main code. Every usage of x and y in the main code is guaranteed to be atomic by disabling interrupts. Do x and y really need to be volatile , or is it enough to put a memory barrier before using them to force reloading the variables from RAM? A) volatile bool x; volatile int y[100]; int

Why does Threads in BLOCKED state do not get interrupted?

拥有回忆 提交于 2019-12-02 00:57:00
Off late i am working on multithreading in java. Want to understand if a Thread is in BLOCKED state why it cant be interrupted? And why the thread can be interrupted only if it is in WAIT state? Basically, why do we need two Thread states one which can be interrupted and the other which cant be interrupted? This question might be very basic but, I am trying to understand things rather than just remembering them. One assumes that you mean cause the thread to stop its current operation and throw an InterruptedException ? A thread interrupt in Java is just a flag. You can call interrupt() just

how to interrupt a scanner.nextline() call

[亡魂溺海] 提交于 2019-12-02 00:31:07
There are many threads on SO about interrupting reading the system.in but what I am looking for here is some kind of advice as to how to best code what I am trying to achieve. I have a getlogin() method that needs to do the following: ask a user to input the desired login environnement details, if after 6 seconds user have not input a valid value ("live" or "test") then set userlogin variable to "test" and return it to the caller. I have taken the following approach for the getlogin() implementation: launch two threads which do the following: thread1 creates a scanner object then calls scanner

During an x86 software interrupt, when exactly is a context switch made?

↘锁芯ラ 提交于 2019-12-02 00:29:37
I am asking this because I am trying to implement interrupts in my toy kernel. So, I know that when an interrupt occurs, the CPU pushes various bits of information onto the stack. However, everywhere I search online shows different information in different order being pushed. I also know that if the interrupt occurred in user mode (Ring 3), the CPU must switch to kernel mode (Ring 0) before it can execute the ISR. I think it has something to do with the TSS and ss and esp , however I am not sure. I have read various different explanations all over the internet and have not found any uniformity

How to allow Web Workers to receive new data while it still performing computation?

点点圈 提交于 2019-12-02 00:08:41
I want to sort an array, using Web Workers. But this array might receive new values over time, while the worker is still performing the sort function. So my question is, how can I "stop" the sorting computation on the worker after receiving the new item, so it can perform the sort on the array with that item, while still keeping the sorting that was already made? Example: let worker = new Worker('worker.js'); let list = [10,1,5,2,14,3]; worker.postMessage({ list }); setInterval(() => worker.postMessage({ num: SOME_RANDOM_NUM, list }), 100); worker.onmessage = event => { list = event.data.list;

Python multithreading interrupt input()

左心房为你撑大大i 提交于 2019-12-01 23:54:10
Hi I am fairly new to python and I am trying to create a program that starts a thread that after five seconds will interrupt the input () function and print the message “Done!”. Currently it only prints “Done!” after input is given. Even after five seconds has passed, the user must enter input before the message "Done!" is displayed. How can I get the thread to interrupt the input() function? import time import threading def fiveSec(): time.sleep(5) print('Done!') def main(): t = threading.Thread(target = fiveSec) t.daemond = True t.start() input('::>') if __name__ == '__main__': main() (Using

Posting a message to a web worker while it is still running

倖福魔咒の 提交于 2019-12-01 17:55:33
Say we have a web worker referring to a file called "worker.js". We use the worker to execute a function in "worker.js" that does some lengthy operation. We call post the respective message to the worker and proceed in the main thread. However, before the worker has finished doing its initial work, the main thread posts another message to it. My question: Will the worker continue with our time-taking function and only process the newly posted message once finished or will it interrupt its current operation until the new one has been completed? I've tried out the following code in Google Chrome

Why is my masm32 program crashing whenever I try using interrupts?

孤街浪徒 提交于 2019-12-01 17:54:14
问题 Here's the code: .386 ;target for maximum compatibility .model small,stdcall ;model .code main: int 20h END main Result: http://img705.imageshack.us/img705/3738/resultom.png "test.exe has stopped working" - always right when it reaches the interrupt. This is the interrupt I'm trying to use. It should simply exit the program. Others I've tried include character input/output, etc.. Nothing works. I'm on windows 7, using masm32 with the WinAsm IDE. There are so many cool things it seems I should

Why can't Thread.interrupt() interrupt a thread trying to acquire lock

拟墨画扇 提交于 2019-12-01 17:45:57
In the book Thinking in Java it is written that Thread.interrupt() cannot interrupt a thread which is trying to acquire a synchronized lock, I want to know why? A blocking operation can be interrupted only if it is declared to throw InterruptedException . Clearly, a synchronized block does not declare it, therefore it is impossible to interrupt a thread while it is waiting to acquire a lock. Alternatively you can use an explicit lock and call Lock.lockInterruptibly() . The book is wrong, unless it is only referring to the synchronized keyword. Object.wait() throws InterruptedException . 来源: