interrupt

XMega Timer and Microseconds

馋奶兔 提交于 2019-12-11 03:30:24
问题 I'm trying to bit bang out some data out of an atxmega128a3u and need to toggle a pin as fast as 4us but so far I'm not getting anywhere close to that... Here I'm setting my timer for 88us but am getting around 146us. int main(void) { //CRYSTAL SETUP OSC_XOSCCTRL = OSC_FRQRANGE_12TO16_gc | OSC_XOSCSEL_XTAL_16KCLK_gc; // 16Mhz Crystal OSC_CTRL |= OSC_XOSCEN_bm; while(!(OSC_STATUS & OSC_XOSCRDY_bm)); //Wait for crystal to stabilize. CCP = CCP_IOREG_gc; CLK_CTRL = CLK_SCLKSEL_XOSC_gc; //END

Python - Handle CTRL+D with 'import signal'

不羁岁月 提交于 2019-12-11 02:07:58
问题 I can currently handle CTRL + C via: def hand_inter(signum, frame): print 'hey, nice job.' signal.signal(signal.SIGINT, hand_inter) However I am required to also handle CTRL + D yet cannot find the appropriate "signal.CTRL+D" call for signum. 回答1: Ctrl + D is not a signal, it's end of file. If you have an interactive program, you will be most probably reading STDIN and Ctrl + D is way how user says that the input is over. Outside this context it does not have any special meaning. The code

Interrupting syscalls in threads on linux

跟風遠走 提交于 2019-12-11 01:38:57
问题 I have a pthread that runs in a loop, calling accept() in a blocking manner. Is there any way to interrupt that call from another thread? Everything points to sending the thread a signal, but apparently you can only send a process a signal. I can't just kill the thread because then it leaves the socket open. And that's not very clean anyway. Is there really no way to do this? 回答1: You can signal a thread using pthread_kill(3). The pthread_kill() function sends the signal sig to thread,

Fixing race condition when sending signal to interrupt system call

折月煮酒 提交于 2019-12-11 00:43:15
问题 I have a thread that read() s from a socket, and I want to be able to stop the thread asynchronously. The thread pseudocode looks like: int needs_quit = 0; void *thread_read(void *arg) { while(1) { if(needs_quit) { close(sock_fd); return NULL; } int ret = read(sock_fd ...); if(ret == EINTR) //we received an interrupt signal to stop { close(sock_fd); return NULL; } //do stuff with read data } } The signal handler simply sets needs_quit to 1. Most of the time, this code will work. But, if a

Avoiding CortexM Interrupt Nesting

早过忘川 提交于 2019-12-11 00:23:08
问题 I want to avoid nested interrupts at the interrupts entry in a CortexM based microcontroller. To achieve this I have an assembly file containing interrupt vectors and first instruction of each vector is the instruction ( CPSID I ) to disable interrupts globally. After every individual interrupt handler(written in C), execution returns to a common assembly routine which re-enables the interrupts with instruction CPSIE I and return from Interrupt/Exception process is triggered with instruction

timer interrupt thread python

半世苍凉 提交于 2019-12-10 22:13:06
问题 I've been trying to make a precise timer in python, or as precise a OS allows it to be. But It seams to be more complicated than I initially thought. This is how I would like it to work: from time import sleep from threading import Timer def do_this(): print ("hello, world") t = Timer(4, do_this) t.start() sleep(20) t.cancel() Where during 20 seconds I would execute 'do_this' every fourth second. However 'do_this' executes once then the script terminates after 20 seconds. Another way would be

C# Is it possible to interrupt a specific thread inside a ThreadPool?

可紊 提交于 2019-12-10 19:48:52
问题 Suppose that I've queued a work item in a ThreadPool , but the work item blocks if there is no data to process (reading from a BlockingQueue ). If the queue is empty and there will be no more work going into the queue, then I must call the Thread.Interrupt method if I want to interrupt the blocking task, but how does one do the same thing with a ThreadPool ? The code might look like this: void Run() { try { while(true) { blockingQueue.Dequeue(); doSomething(); } } finally { countDownLatch

What are legacy interrupts?

邮差的信 提交于 2019-12-10 19:44:34
问题 I am working on a project where i am trying to figure out how an interrupt is processed in the Global interrupt controller for a ARM architecture. I am working with pl390 interrupt controller. I see there is a line which is mentioned as legacy interrupts which bypasses the distributor logic. It is given that 2 interrupts can be programmed as a legacy interrupt. Can any one help with some explanation of what exactly is a legacy interrupt?. I trying searching online without any luck. 回答1:

jQuery delay function interrupt

◇◆丶佛笑我妖孽 提交于 2019-12-10 18:31:07
问题 I have a pop-up window in jQuery that fades in, and will fade out in 10 seconds if not dismissed by the user. I have the code: $modalElement.fadeIn(1000).delay(10000).fadeOut(1000); And this works fine for the fade in, delay and fade out - but the 'close' button on the form doesnt work until after the timeout! I need the 'close' button to interupt the delay , so that the user can read the pop up and close it themselves, say, at 5 seconds - and then if they havent closed it themselves, then it

A simple assembly code cause a segment fault?

点点圈 提交于 2019-12-10 18:25:01
问题 .section .data .section .text .globl _start _start: movl $1, %eax # this is the linux kernel command # number (system call) for exiting # a program movl $4, %ebx # this is the status number we will # return to the operating system. # Change this around and it will # return different things to # echo $? int $0x80 # this wakes up the kernel to run # the exit command But if I remove the last line of code int 0x80 , then it'll cause a segment fault . I don't know why? Can anyone tell me. Thanks