打印

关于ucos的中断内任务切换

[复制链接]
3738|8
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
jfzd|  楼主 | 2008-1-11 12:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
沙发
wlq_9| | 2008-1-11 13:06 | 只看该作者

不能这样乱来

你可以在任务中禁止调度即可.

使用特权

评论回复
板凳
dld2| | 2008-1-11 13:18 | 只看该作者

顶楼上

使用特权

评论回复
地板
jfzd|  楼主 | 2008-1-11 13:35 | 只看该作者

谢谢楼上两位

我现在就是这么做的,但感觉好麻烦,我的IIC接有RTC,EEP,ZLG7290分别在不同的任务中,老是要禁止任务调度,有没有那个宏可以禁止掉任务切换?

使用特权

评论回复
5
dld2| | 2008-1-11 13:48 | 只看该作者

用一个独立的任务处理IIC

其它任务和它通讯。

使用特权

评论回复
6
wlq_9| | 2008-1-11 13:50 | 只看该作者

估计

楼上的是要资源互斥,用个信号量保护即可.
任务调度锁有函数可用
void          OSSchedLock           (void);
void          OSSchedUnlock         (void);

使用特权

评论回复
7
M理论| | 2008-1-12 19:57 | 只看该作者

提高你任务的优先级不行吗??

??????????????????

使用特权

评论回复
8
gliethttp| | 2008-1-13 11:18 | 只看该作者

这样试试,看看行不行

//---------------------------------------------------
//修改之前原有的OSIntExit()函数体
void  OSIntExit (void)
{
    INT8U      y;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
    
    

    cpu_sr = 0;                                            /* Prevent compiler warning                 */
#endif    
    if (OSRunning == TRUE) {
        OS_ENTER_CRITICAL();
        if (OSIntNesting > 0) {                            /* Prevent OSIntNesting from wrapping       */
            OSIntNesting--;
        }
        if (OSIntNesting == 0) {                           /* Reschedule only if all ISRs complete ... */
            if (OSLockNesting == 0) {                      /* ... and not locked.                      */
                y             = OSUnMapTbl[OSRdyGrp];          
                OSPrioHighRdy = (INT8U)((y << 3) + OSUnMapTbl[OSRdyTbl][y]]);
                if (OSPrioHighRdy != OSPrioCur) {          /* No Ctx Sw if current task is highest rdy */
                    OSTCBHighRdy  = OSTCBPrioTbl[OSPrioHighRdy];
#if OS_TASK_PROFILE_EN > 0
                    OSTCBHighRdy->OSTCBCtxSwCtr++;         /* Inc. # of context switches to this task  */
#endif
                    OSCtxSwCtr++;                          /* Keep track of the number of ctx switches */
                    OSIntCtxSw();                          /* Perform interrupt level ctx switch       */
                }
            }
        }
        OS_EXIT_CRITICAL();
    }
}
//---------------------------------------------------
//修改之后的OSIntExit()函数体
void  OSIntExit (void)
{
    INT8U      y;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
    
    

    cpu_sr = 0;                                            /* Prevent compiler warning                 */
#endif    
    if (OSRunning == TRUE) {
        OS_ENTER_CRITICAL();
        if (OSIntNesting > 0) {                            /* Prevent OSIntNesting from wrapping       */
            OSIntNesting--;
        }
        OS_EXIT_CRITICAL();
    }
}

使用特权

评论回复
9
nuaajray| | 2013-11-18 09:29 | 只看该作者
你好,我也遇到了类似的问题,现在的要求是禁止在UCOS中断中进行任务切换,而把任务切换放在任务中进行,请问您是怎么解决的?还望赐教

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

13

主题

26

帖子

0

粉丝