eventset

更新时间:
2024-01-09
下载文档

eventset

展示事件集信息。

格式

eventset eventset handle

说明

[root@sylixos:/root]# help eventset
show eventset information.
eventset eventset handle
[root@sylixos:/root]# 

此命令用于显示事件集的相关信息。

样例

使用SylixOS事件集操作函数编写程序,打印事件集ID号。


[root@sylixos:/apps/event_test]# ./event_test &
[root@sylixos:/apps/event_test]# tp
thread pending show >>

      NAME         TID    PID  STAT    DELAY          PEND EVENT        OWNER
---------------- ------- ----- ---- ---------- ----------------------- -------
t_itimer         4000001     0 SLP       82045        0:
t_isrdefer       4000002     0 SEM           0 10000002:job_sync
t_except         4000003     0 SEM           0 10000003:job_sync
t_log            4000004     0 MSGQ          0 1c000004:log_msg:R
t_power          4000005     0 SLP         257        0:
t_hotplug        4000006     0 SEM         256 10000015:job_sync
t_reclaim        4000008     0 MSGQ          0 1c000021:res_reclaim:R
t_sync           4000009     0 SLP         214        0:
t_dcwpipe        400000a     0 SEM           0  c00005c:dc_mq
t_tpsfs          400000b     0 SLP         201        0:
t_console        400000c     0 MSGQ          0 1c0000cc:xkbd_q:R
t_netjob         400000d     0 SEM           0 10000088:job_sync
t_netproto       400000e     0 MSGQ         11 1c00008c:net_msg:R
t_snmp           400000f     0 MSGQ          0 1c00009c:net_msg:R
t_ftpd           4000010     0 MSGQ          0 1c0000c1:net_msg:R
t_telnetd        4000011     0 MSGQ          0 1c0000c2:net_msg:R
t_jobq           4000013     0 SEM           0 100000b8:job_sync
t_xinput         4000015     0 SEM           0 100000d2:sel_wakeup
t_xcondev        4000016     0 MSGQ          0 1c0000d7:xcon_cq:R
main.jsc         4000017     1 SEM           0 100000e0:sel_wakeup
t_tshell         400001a     0 SEM           0 10000040:ty_rsync
jsre_timer       400001b     1 VUTX        187  f122940:2626
imgpull.jsc      400001c     1 SEM           0 10000224:sel_wakeup
assistant.jsc    400001d     1 SEM           0 10000276:sel_wakeup
event_test       400002e    10 JOIN          0  400002f:t_testa
t_testa          400002f    10 ENTS          0 20000006:event_set
t_testb          4000030    10 SLP         195        0:

pending thread: 27
[root@sylixos:/apps/event_test]# eventset 20000006
event set show >>

event set name  : event_set
event set event : 0xffffffff00000000

[root@sylixos:/apps/event_test]#

字段说明:

字段说明
event set name事件集名
event set event事件集当前事件

event_test 示例代码:

下面程序展示了 SylixOS 事件集的使用,程序创建两个线程和一个 SylixOS 事件集;线程 tTestB 不断地发送 0 到 31 号事件,线程 tTestA 等待事件并不处理事件。

#include <SylixOS.h>

static LW_HANDLE    _G_hEventSet;

static PVOID tTestA (PVOID  pvArg)
{
    INT      iError;
    ULONG    ulEvent;
    INT      i;

    while (1) {
        iError = Lw_Event_WaitEx(_G_hEventSet,
                                 LW_OPTION_EVENT_ALL,
                                 LW_OPTION_EVENTSET_WAIT_SET_ANY |
                                 LW_OPTION_EVENTSET_RESET,
                                 LW_OPTION_WAIT_INFINITE,
                                 &ulEvent);
        if (iError != ERROR_NONE) {
            break;
        }
        for (i = 0; i < 32; i++) {
            if (ulEvent & (1 << i));
        }
    }
    return  (LW_NULL);
}

static PVOID tTestB (PVOID  pvArg)
{
    INT     iError;
    INT     i;

    while (1) {
        for (i = 0; i < 32; i++) {
            iError = Lw_Event_Send(_G_hEventSet, (1 << i), LW_OPTION_EVENTSET_SET);
            if (iError != ERROR_NONE) {
                return  (LW_NULL);
            }
            Lw_Time_SSleep(1);
        }
    }
    return  (LW_NULL);
}
int main (int argc, char *argv[])
{
    LW_HANDLE         hThreadAId;
    LW_HANDLE         hThreadBId;

    _G_hEventSet = Lw_Event_Create("event_set", 0,
                                   LW_OPTION_WAIT_FIFO |
                                   LW_OPTION_OBJECT_LOCAL,
                                   LW_NULL);
    if (_G_hEventSet == LW_OBJECT_HANDLE_INVALID) {
        printf("event set create failed.\n");
        return  (-1);
    }
    hThreadAId = Lw_Thread_Create("t_testa", tTestA, LW_NULL, LW_NULL);
    if (hThreadAId == LW_OBJECT_HANDLE_INVALID) {
        printf("t_testa create failed.\n");
        return  (-1);
    }
    hThreadBId = Lw_Thread_Create("t_testb", tTestB, LW_NULL, LW_NULL);
    if (hThreadBId == LW_OBJECT_HANDLE_INVALID) {
        printf("t_testb create failed.\n");
        return  (-1);
    }
    Lw_Thread_Join(hThreadAId, LW_NULL);
    Lw_Thread_Join(hThreadBId, LW_NULL);
    Lw_Event_Delete(&_G_hEventSet);

    return  (0);
}

文档内容是否对您有所帮助?
有帮助
没帮助