interrupt

Thread.Interrupt to stop long sleep at app shutdown - Is there a better approach

Deadly 提交于 2019-12-03 03:38:34
I'm having a small background thread which runs for the applications lifetime - however when the application is shutdown, the thread should exit gracefully. The problem is that the thread runs some code at an interval of 15 minutes - which means it sleeps ALOT. Now in order to get it out of sleep, I toss an interrupt at it - my question is however, if there's a better approach to this, since interrupts generate ThreadInterruptedException. Here's the gist of my code (somewhat pseudo): public class BackgroundUpdater : IDisposable { private Thread myThread; private const int intervalTime = 900000

How to detecting interrupt on a GPIO line in Embedded Linux?

僤鯓⒐⒋嵵緔 提交于 2019-12-03 03:35:51
There is an interrupt being generated at every 10ms on GPIO_39 in the pandaboard OMAP4 . I have registered a handler for this in Linux driver code, but the handler is not being called since the interrupt is not being detected. I made sure at the hardware level (by probing the gpio pin) that the interrupt is actually being generated. It's only that the software is not being able to detect it. I've the following in my driver code. #define GPIO_NO 39 iowrite16(0x3, gpio_39_address + 2); /* Configured the pin 22 to be used as gpio. */ ret = gpio_request(GPIO_NO, "Claiming GPIO"); if(ret < 0) {

Evaluating SMI (System Management Interrupt) latency on Linux-CentOS/Intel machine

早过忘川 提交于 2019-12-03 03:21:30
I am interested in evaluating the behavior (latency, frequency) of SMI handling on Linux machine running CentOS and used for a (very) soft real time application. What tools are recommended (hwlatdetect for CentOS?), and what is the best course of action to go about this? If no good tools are available for CentOS, am I correct to assume that installing a different OS on the same machine should yield the same results since the underlying hardware/bios are the same? Is there any source for ballpark figures on these parameters. The machines are X86_64 architecture, running CentOS 6.4 (kernel 2.6

Interrupting blocked read

不想你离开。 提交于 2019-12-03 02:07:46
My program goes through a loop like this: ... while(1){ read(sockfd,buf,sizeof(buf)); ... } The read function blocks when it is waiting for input, which happens to be from a socket. I want to handle SIGINT and basically tell it to stop the read function if it is reading and then call an arbitrary function. What is the best way to do this? From read(2) : EINTR The call was interrupted by a signal before any data was read; see signal(7). If you amend your code to look more like: cont = 1; while (1 && cont) { ret = read(sockfd, buf, sizeof(buf)); if (ret < 0 && errno == EINTR) cont = arbitrary

How to properly handle audio interruptions?

我的梦境 提交于 2019-12-03 00:52:55
I've created a OpenGL 3D game utilizing OpenAL for audio playback and experienceing a problem of losing audio if "Home" button is getting pressed before audio device is getting initialized. I tried to hook up to audio session interrupt handler, but my callback is never getting called. No matter if I minimize or maximize my application. My "OpenALInterruptionListener" is never getting called. What am I doing wrong? AudioSessionInitialize(NULL, NULL, OpenALInterriptionListener, this); void OpenALInterriptionListener(void * inClientData, UInt32 inInterruptionState) { OpenALDevice * device =

Stopping C++ 11 std::threads waiting on a std::condition_variable

ε祈祈猫儿з 提交于 2019-12-02 20:16:54
I am trying to understand the basic multithreading mechanisms in the new C++ 11 standard. The most basic example I can think of is the following: A producer and a consumer are implemented in separate threads The producer places a certain amount of items inside a queue The consumer takes items from the queue if there are any present This example is also used in many school books about multithreading and everything about the communication process works fine. However, I have a problem when it comes to stopping the consumer thread. I want the consumer to run until it gets an explicit stop signal

How do interrupts work on multicore ARM cpu

﹥>﹥吖頭↗ 提交于 2019-12-02 19:50:03
This question has already been answered for x86 however, I couldn't find much about ARM MP cpus like Cortex-A9, Cortex-A15 etc... More importantly i want to know if interrupts can be raised on non-primary cpu without any configuration etc. I am working on a software which deals only with the primary cpu hence i put the rest in WFI state however I am unaware of how interrupts work on the MP arm cpus, Is it possible that the main cpu continues executing code and one of the secondary cpu picks it up and jumps to the instruction in vector table and execute that code ? btw here is the code I'm

how to know the Interrupt/GPIO number for a specific pin in linux

有些话、适合烂在心里 提交于 2019-12-02 17:45:46
i'm doing a project in which i need to handle an interrupt in Linux. the board i'm using is an ARM9Board based on the s3c6410 MCU by Samsung (arm 11 processor) and it has the following I/O interface : as the image shows i have EINTx pins for external interrupts and GPxx pins as GPIO pins and i don't mind using any of them but i don't have their numbers ! For EINTx pins : when i call int request_irq(unsigned int irq, void (*handler)(int, struct pt_regs *), unsigned long flags, const char *device); i need the interrupt number to pass it as the first paramter of the function , so how can i get

What context does the scheduler code run in?

拥有回忆 提交于 2019-12-02 17:43:08
There are two cases where the scheduler code schedule() is invoked- When a process voluntarily calls schedule() Timer interrupt calls schedule() In case 2, I think schedule() runs in interrupt context, but what about the first case? Does it run in the context of the process which invoked it? Also are there any more scenarios which invoke schedule() ? schedule() always runs in process context. In the second case, when it is initiated by a timer interrupt, it is in the return path back from the kernel to the interrupted process where schedule() is called. __schedule() is the main scheduler

How exactly does Thread.interrupt() and Thread.interrupted() work? [duplicate]

旧时模样 提交于 2019-12-02 15:11:40
问题 This question already has answers here : What does java.lang.Thread.interrupt() do? (9 answers) Closed 6 years ago . I am not clear regarding these two methods from the perspective of setting the status of the thread. Java Docs say that Thread.interrupt() sets the threads interrupt status flag and calling the Thread.interrupted() method gives the status of the thread and clears the flag. When this comes to use in real scenarios..?? 回答1: When some other thread calls Thread.interrupt() the