/*----------------------------------------------------------------------------
* RL-ARM - RTX
*----------------------------------------------------------------------------
* Name: RTX_EX1.C
* Purpose: Your First RTX example program
*----------------------------------------------------------------------------
*
* Copyright (c) 1999-2009 KEIL, 2009-2012 ARM Germany GmbH
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/ #include "cmsis_os.h" /* Forward reference */
void threadX (void const *argument); /* Thread IDs */
osThreadId main_id;
osThreadId threadX_id; /* Thread definitions */
osThreadDef(threadX, osPriorityNormal, , ); /*----------------------------------------------------------------------------
* Thread X
*---------------------------------------------------------------------------*/
void threadX (void const *argument) {
for (;;) {
/* Wait for completion of do-this */
osSignalWait(0x0004, osWaitForever); /* do-that */
/* Pause for 20 ms until signaling event to main thread */
osDelay();
/* Indicate to main thread completion of do-that */
osSignalSet(main_id, 0x0004);
}
} /*----------------------------------------------------------------------------
* Main Thread
*---------------------------------------------------------------------------*/
int main (void) { /* Get main thread ID */
main_id = osThreadGetId();
/* Create thread X */
threadX_id = osThreadCreate(osThread(threadX), NULL);
for (;;) { /* do-this */
/* Indicate to thread X completion of do-this */
osSignalSet(threadX_id, 0x0004);
/* Wait for completion of do-that */
osSignalWait(0x0004, osWaitForever);
/* Wait now for 50 ms */
osDelay();
}
} /*----------------------------------------------------------------------------
* end of file
*---------------------------------------------------------------------------*/

CMSIS Example - Signal的更多相关文章

  1. CMSIS Example - Signal and Yield

    /*---------------------------------------------------------------------------- * RL-ARM - RTX *----- ...

  2. java 线程 Lock 锁使用Condition实现线程的等待(await)与通知(signal)

    一.Condition 类 在前面我们学习与synchronized锁配合的线程等待(Object.wait)与线程通知(Object.notify),那么对于JDK1.5 的 java.util.c ...

  3. Linux 信号(二)—— signal 函数

    弗洛伊德认为:要解决这些苦恼,当事人就要通过回忆并理解自己早期的童年经历,来获得对潜意识冲突的顿悟.弗洛伊德的疗法被称为“精神分析” (psychoanalysis),在 20 世纪的很长一段时间被心 ...

  4. Fatal signal xx (SIGSEGV) at

    Fatal signal 11问题的解决方法 http://blog.csdn.net/tankai19880619/article/details/9004619 如何定位Android NDK开发 ...

  5. php php-5.6.4.tar.bz2 apache 兼容问题 child pid 27858 exit signal Segmentation fault

    环境 [root envirotar]# uname -a Linux i2..el6.x86_64 # SMP Thu Jul :: UTC x86_64 x86_64 x86_64 GNU/Lin ...

  6. QT 中 关键字讲解(emit,signal,slot)

    Qt中的类库有接近一半是从基类QObject上继承下来,信号与反应槽(signals/slot)机制就是用来在QObject类或其子类间通讯的方法.作为一种通用的处理机制,信号与反应槽非常灵活,可以携 ...

  7. C标准头文件<signal.h>

    信号即异常,或者理解为中断,一个进程接收到一个信号,如果没有处理机制,就会按照默认的处理方式进行处理,而默认的处理方式通常是终止当前进程或忽略该信号.当然,程序也可以编写相应的处理信号的函数,一旦接收 ...

  8. qthread 使用 signal 方法通信

    因为之间尝试过的 signal 机制,都是在 emit singnal_my() 的地方,直接调用了 slot 函数:相当于,slot 只是一个回调函数. 所以,在这里有点困惑,如果是要顺序执行完 s ...

  9. Linux进程间通信(一): 信号 signal()、sigaction()

    一.什么是信号 用过Windows的我们都知道,当我们无法正常结束一个程序时,可以用任务管理器强制结束这个进程,但这其实是怎么实现的呢?同样的功能在Linux上是通过生成信号和捕获信号来实现的,运行中 ...

随机推荐

  1. android 横竖屏限制如何配置

    在开发android的应用中,有时候需要限制横竖屏切换.只需要在AndroidManifest.xml文件中加入android:screenOrientation属性限制. ndroid:screen ...

  2. C#的Timer

    PowerCoder 原文 C#的Timer 再C#里现在有3个Timer类: System.Windows.Forms.Timer System.Threading.Timer System.Tim ...

  3. [搜片神器]直接从DHT网络下载BT种子的方法

    DHT抓取程序开源地址:https://github.com/h31h31/H31DHTDEMO 数据处理程序开源地址:https://github.com/h31h31/H31DHTMgr DHT系 ...

  4. std::vector数据复制

    std::vector<boost::shared_ptr <ITEM> > srcItemList;  // 数据源 std::vector<ITEM>  des ...

  5. delphi 中 image 控件加载bmp、JPG、GIF、PNG等图片的办法

    procedure TForm1.Button1Click(Sender: TObject);var  jpg: TJPEGImage; // 要use Jpeg单元begin  // 显示jpg大图 ...

  6. 从今天开始写博客、托管代码到 Github

    最近看了一篇文章,译名<简历危险>,原名<Resumes are dangerous>. 作者为Alex Maccaw,他有一篇文章曾经在网上流传甚广——<Traveli ...

  7. Google搜索的常用技巧

    个人搜索方案 1.选择合适的搜索词,一些行业术语或专家名字可以带来更加高质量的结果. 2.搜索词手动使用空格分隔,先进行第一次搜索,看搜索结果标题是否满足预期,如果不满足,采用更换关键词,添加关键词, ...

  8. 【LeetCode】102 - Binary Tree Level Order Traversal

    Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, ...

  9. Chapter7:类

    关于this指针 成员函数通过一个名为this的额外的隐式参数来访问调用它的对象.当我们调用一个成员函数时,用请求该函数的对象初始化this. total.isbn(); //等价于编译器重写为 Sa ...

  10. 调用openoffice Com组件转换成PDF

    //例子 OpenOfficeExportToPDF('file:///C:/SourceFile.odt', 'file:///C:/TargetFile.pdf');   必须为URL格式的路径 ...