标签: interrupt

调度程序代码在什么上下文中运行?

schedule()调用调度程序代码有两种情况 -

  1. 当进程自愿调用时 schedule()

  2. 定时器中断调用 schedule()

在案例2中,我认为schedule()在中断上下文中运行,但第一种情况呢?它是在调用它的进程的上下文中运行的吗?

还有更多场景可以调用schedule()吗?

linux scheduling interrupt linux-kernel

12
推荐指数
1
解决办法
5492
查看次数

如何正确处理音频中断?

我创建了一个利用OpenAL进行音频播放的OpenGL 3D游戏,如果在音频设备初始化之前按下"Home"按钮,则会遇到丢失音频的问题.我试图连接到音频会话中断处理程序,但我的回调永远不会被调用.无论我是最小化还是最大化我的申请.永远不会调用我的"OpenALInterruptionListener".

我究竟做错了什么?

AudioSessionInitialize(NULL, NULL, OpenALInterriptionListener, this);

void OpenALInterriptionListener(void * inClientData, UInt32 inInterruptionState)
{
    OpenALDevice * device = (OpenALDevice *) inClientData;

    if (inInterruptionState == kAudioSessionBeginInterruption)
    {
          alcSuspendContext(_context);
          alcMakeContextCurrent(_context);
          AudioSessionSetActive(false);
    }
    else if (inInterruptionState == kAudioSessionEndInterruption)
    {
          UInt32 sessionCategory = kAudioSessionCategory_AmbientSound;
          AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
          AudioSessionSetActive(true);    
          alcMakeContextCurrent(_context);
          alcProcessContext(_context);
    }
}
Run Code Online (Sandbox Code Playgroud)

c++ audio interrupt openal ios

12
推荐指数
1
解决办法
1766
查看次数

如何使无滴答内核工作?nohz_full,rcu_nocbs,isolcpus还有什么?

我刚刚用新的3.11内核安装了Ubuntu 13.10.在3.10中,它具有无滴漏功能,我可以在不受本地定时器中断的情况下运行进程,而不像以前那么多.我关注此链接http://www.breakage.org/2013/11/nohz_fullgodmode/

我计划在cpu 3上运行我的应用程序,所以我在grub中设置以下内容:

isolcpus=3 nohz_full=3 rcu_nocbs=3
Run Code Online (Sandbox Code Playgroud)

重新启动后,似乎cpu 3上的本地定时器中断确实比其他cpu要少很多.

我也跑了:

# for i in `pgrep rcu` ; do taskset -pc 0 $i ; done
Run Code Online (Sandbox Code Playgroud)

但是当我开始运行我的应用程序时,本地计时器中断的计数跳了起来.我的应用程序只做无限循环.

int main() {
while (true) {
}
}
Run Code Online (Sandbox Code Playgroud)

那我错过了什么?当我运行时,为什么时间中断会回来?我认为nohz_full意味着当只有一个进程在运行时,它将停止中断.

以下是/ proc/sched_debug的输出,当我没有运行应用程序时,显然在该cpu上没有其他进程.那我错过了什么?

cpu#3, 2492.071 MHz
  .nr_running                    : 0
  .load                          : 0
  .nr_switches                   : 45818
  .nr_load_updates               : 11165
  .nr_uninterruptible            : -1
  .next_balance                  : 4295.674289
  .curr->pid                     : 0
  .clock                         : 3127610.519188
  .cpu_load[0]                   : 0
  .cpu_load[1]                   : 0
  .cpu_load[2]                   : 0
  .cpu_load[3]                   : 0
  .cpu_load[4]                   : 0
  .yld_count …
Run Code Online (Sandbox Code Playgroud)

linux latency timer interrupt linux-kernel

12
推荐指数
1
解决办法
5235
查看次数

你如何测试你的中断处理模块?

我有一个中断处理模块,它控制嵌入式处理器上的中断控制器硬件.现在我想为它添加更多测试.目前,测试仅测试中断嵌套是否有效,方法是在ISR中进行两次软件中断,一次是低优先级,另一次是高优先级.如何进一步测试该模块?

c testing embedded interrupt

11
推荐指数
1
解决办法
3854
查看次数

信号中断的系统调用仍然需要完成

许多系统调用都close( fd )可以被信号中断.在这种情况下,通常-1会返回并errno设置EINTR.

问题是做什么是正确的?说,我仍然希望fd关闭它.

我能想到的是:

while( close( fd ) == -1 )
  if( errno != EINTR ) {
    ReportError();
    break;
  }
Run Code Online (Sandbox Code Playgroud)

任何人都可以建议更好/更优雅/标准的方式来处理这种情况吗?

更新:正如mux所注意到的,RESTART在安装信号处理程序时可以使用SA_ 标志.有人可以告诉我哪些功能可以保证在所有POSIX系统上都可以重启(不仅仅是Linux)?

c c++ unix interrupt eintr

11
推荐指数
1
解决办法
3858
查看次数

如何保持中断时间短?

嵌入式编程中最常听到的建议是"保持中断时间短".

现在我的情况是我的main()循环中有一个非常长的运行任务(将大块数据写入SD卡),有时需要100ms.因此,为了保持我的系统响应,我将所有其他内容移动到了中断处理程序.

例如,通常可以在中断中处理传入的UART数据,然后在main()循环中处理传入的命令,然后发回响应.但在我的情况下,命令的整个处理/处理也在中断中进行,因为我的main()循环可以被阻塞(相对)长时间.

最佳解决方案是切换到RTOS,但我没有RAM.我的设计是否有替代方案可以缩短中断时间?

embedded arm interrupt firmware interrupt-handling

11
推荐指数
2
解决办法
1758
查看次数

为什么在实现Runnable时使用Thread.currentThread().isInterrupted()而不是Thread.interrupted()?

在stackoverflow上,我经常看到使用Thread.currentThread().isInterrupted().Runnable在while循环中实现和使用它时,如下所示:

public void run() {
  while(!Thread.currentThread().isInterrupted()) { ... }
}
Run Code Online (Sandbox Code Playgroud)

是否有任何不同使用Thread.interrupted()(除了interrupted使用时清除标志interrupted())?

我也见过Thread.currentThread().interrupted().这是正确的使用方式,还是Thread.interrupted()足够的?

java multithreading interrupt runnable

11
推荐指数
2
解决办法
6971
查看次数

PCIe插槽的中断路由直接连接到CPU

如果我们今天查看Haswell架构图,我们可以看到有PCIe通道直接连接到CPU(用于图形)以及其中一些路由到平台控制器集线器(南桥更换): 英特尔C22X芯片组图

如果我们看一下英特尔8系列数据表(C222的规格),我们会发现英特尔C222包含用于路由传统INTx中断的I/O APIC(第5.10章).我的问题是,如果传统的INTx中断请求直接到达CPU(通过PCIe 3.0通道)会发生什么.是否必须首先转发到C222,还是系统代理中还有另一个I/O APIC,在这种情况下我必须编程?此外,借助用于定向I/O的英特尔虚拟化技术,现在还有一个额外的间接,即中断重映射表.在CPU或C222上的系统代理(前北桥)中的那个表是否意味着在启用重映射的情况下,需要首先将PCIe 3.0通道的所有中断路由到C222?

operating-system x86-64 intel interrupt pci-e

11
推荐指数
1
解决办法
537
查看次数

PyQt4:如何在发出信号之前暂停线程?

我有以下pyqtmain.py:

#!/usr/bin/python3
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from pyqtMeasThread import *


class MainWindow(QMainWindow):
    def __init__(self, parent=None):
        self.qt_app = QApplication(sys.argv)
        QMainWindow.__init__(self, parent)

        buttonWidget = QWidget()
        rsltLabel = QLabel("Result:")
        self.rsltFiled = QLineEdit()
        self.buttonStart = QPushButton("Start")

        verticalLayout = QVBoxLayout(buttonWidget)
        verticalLayout.addWidget(rsltLabel)
        verticalLayout.addWidget(self.rsltFiled)
        verticalLayout.addWidget(self.buttonStart)

        butDW = QDockWidget("Control", self)
        butDW.setWidget(buttonWidget)
        self.addDockWidget(Qt.LeftDockWidgetArea, butDW)

        self.mthread = QThread()  # New thread to run the Measurement Engine
        self.worker = MeasurementEngine()  # Measurement Engine Object

        self.worker.moveToThread(self.mthread)
        self.mthread.finished.connect(self.worker.deleteLater)  # Cleanup after thread finished

        self.worker.measure_msg.connect(self.showRslt)

        self.buttonStart.clicked.connect(self.worker.run)

        # Everything …
Run Code Online (Sandbox Code Playgroud)

python multithreading interrupt messagebox pyqt4

11
推荐指数
2
解决办法
4912
查看次数

有没有办法告诉GCC不要重新排序任何指令,而不仅仅是加载/存储?

我正在研究RTOS的irq_lock()/ irq_unlock()实现,并发现了一个问题.我们希望绝对最小化CPU在中断锁定时花费的时间.现在,我们用于x86的irq_lock()内联函数使用"memory"clobber:

static ALWAYS_INLINE unsigned int _do_irq_lock(void)
{
    unsigned int key;

    __asm__ volatile (
        "pushfl;\n\t"
        "cli;\n\t"
        "popl %0;\n\t"
        : "=g" (key)
        :
        : "memory"
        );

    return key;
}
Run Code Online (Sandbox Code Playgroud)

问题是,如果编译器只触及寄存器而不是内存,它仍然会将可能昂贵的操作重新排序到关键部分.我们内核的sleep函数中有一个具体的例子:

void k_sleep(int32_t duration)
{
    __ASSERT(!_is_in_isr(), "");
    __ASSERT(duration != K_FOREVER, "");

    K_DEBUG("thread %p for %d ns\n", _current, duration);

    /* wait of 0 ns is treated as a 'yield' */
    if (duration == 0) {
        k_yield();
        return;
    }

    int32_t ticks = _TICK_ALIGN + _ms_to_ticks(duration);
    int key = irq_lock();

    _remove_thread_from_ready_q(_current);
    _add_thread_timeout(_current, NULL, ticks);

    _Swap(key); …
Run Code Online (Sandbox Code Playgroud)

c interrupt

11
推荐指数
1
解决办法
316
查看次数