Rex Operating System

Source: Internet
Author: User

Http://blog.csdn.net/tiger_ibm/article/details/5305048

Rex (Real-Time Executive) Rex
Rex is a real-time preemptible operating system.
Each Rex task is independently scheduled by the Rex kernel, each task has a Data Structure rex_tcb_struct.tcbs, which is arranged in a single linked list in order of priority-the active and suspended tasks are in the same list. each task will continue to execute to one of the following events and perform context switching.
Voluntarily suspend such as executing rex_wait or rex_timed_wiat
A signal is set in a high-priority pending task.
A task with a higher priority is generated.
An ongoing task has a higher priority than another task.
Interrupted tasks are generated and ISR switches to tasks with a higher priority than the interrupted tasks.
Rex allows tasks to have a priority ranging from 1 to 65535. 1 is the lowest priority. Priority 0 is reserved for idle tasks. No two or more tasks have the same priority. Rex Operating System
Task API: rex_def_task
Priority API: rex_set_pri, rex_task_pri, rex_get_pri.
Rex signal Working principle: the Rex signal is mainly concentrated in two fields of TCB:
SIGs: a mask that includes signals already set for a given task
Wait: a mask that includes some signals. Once these signals are set, the task is suspended.
Signal functions include: rex_wait (), rex_set_sigs (). rex_get_sigs (), rex_clr_sigs ()
Rex Timers: the active Rex timer is a two-way linked list with a rex_timer_struct structure. A rex_timer_struct is allocated for tasks that use the Rex timer, and then the rex_def_timer. rex_set_timer is called to start a timer.
Interrupt handling: The IRQ processor calls tramp_isr and then determines which interrupt is used to generate interaction between. Rex tasks.
Communication between tasks is completed through queues and semaphores.
Tasks that want to send messages to other tasks generate a global command queue and a message related to the queue.
Tasks that want to send messages to other tasks:
Gets the buffer of a command of the type related to the target task.
Fill in the appropriate area
Queue messages to the command queue
Set the interaction between relevant signal Rex tasks for this command (cont .)
Generally, queue operations and set signals are encapsulated into a function. Interaction between Rex tasks (cont .) task A Task B get cmd buffer from Task B and init put cmd buffer to Task B queue set signal for cmd wait signal process signal get cmd from queue and process it environment switch between Rex task and brew interaction
Method 1: The postevent method directly calls ishell_posteven Tex or ishell_postevent in a task of Rex. <Note 1> the main difference between ishell_posteven Tex and, this function allows you to pass multiple events of the same type (the same event Code) to the same Applet and queue events for distribution. Interaction between Rex task and BREW (cont.) <Note 2> If the last parameter of ishell_posteven Tex is a pointer, pay attention to the memory pointed to by the pointer. The memory allocated by calling different malloc or malloc in the high-end platform may come from different heaps. When releasing, the corresponding release function must be used. So we are calling
Before ishell_posteven Tex, copy the data and release the backup memory when the upper-layer app receives the message. Interaction between Rex task and BREW (cont .) the task a brew app calls the API of task a to register the callback function to call the callback function (the execution environment is task a). The callback function calls ishell_posteven Tex to receive the event and process it (the execution environment is aee) environment switching between Rex task and BREW (cont .)
Eg: void wmsapp_cfgcb (uint16 event, wms_cfg * pinfo)

{

Sms_cfg = malloc (sizeof (wms_cfg ));

Memcpy (sms_cfg, pinfo, sizeof (wms_cfg ));

Ishell_posteven tex (pshell, evtflg_async, CLSID, event, sms_cfg );

}

During initialization, wms_client_reg_msg_cb (ID, wmsapp_cfgcb) is called; Rex task interacts with BREW (cont .)
Method 2: use the same method. Call the aee_resumecallback method in the callback instead of the posteven Tex task a brew app to call the API of task a. register the callback function to call the callback function (the execution environment is task ), the callback function calls aee_resumecallback to receive the event and processes it (the execution environment is aee). The Brew and service interaction instance struct iwms {aeevtbl (iwms) * PVT; ishell * m_pishell; aeeclsid m_cls; // No use uint32 um_urefs;
// Reference count}; typedef struct {aeeapplet A; iwms * m_pwms ;... } Cwmsapp; ishell_createinstance (PME->. m_pishell, aeeclsid_wms, (void **) & PME-> m_pwms); // create the WMS interface. First, find the oemwms_new brew and service interaction instance (cont.) through goemstaticclasslist .) static const aeestaticclass goemstaticclasslist []
=={ Aeeclsid_wms, ascf_priv, 0, null, oemwms_new },};
Oemwms_new analysis (oemwms .) static struct iwms * iwmsobj = NULL; // local global variable int oemwms_new (ishell * pishell, aeeclsid CLs, void ** PPIF ){...; // parameter validity check if (iwmsobj = NULL) {If (iwmsobj = (iwms *) oem_malloc (sizeof (iwms) = NULL) {return enomemory ;} brew and service interaction instance (cont .)
Iwmsobj-> PVT = (iwmsvtbl *) & scheme; iwmsobj-> m_pishell = pishell; iwmsobj-> m_cls = CLS; iwmsobj-> m_urefs = 1; * PPIF = iwmsobj ;} else {(void *) oemwms_addref (iwmsobj); * PPIF = iwmsobj;} return aee_success} brew interacts with the service instance (cont .) static const aeevtbl (iwms)
Goemwmsfuncs = {oemwms_addref, oemwms_release, oemwms_queryinterface, oemwms_init,... oemwms_msgdeleteallext}; brew and service interaction instance (cont .)
# Define iwms_addref (P)/aeegetpvtbl (p, iwms)-> addref (p) to call iwms_addref is actually to call oemwms_addref oemwms_release oemwms_queryinterface oemwms_init... oemwms_msgdeleteallext aeevtbl (iwms) * PVT ishell * m_pishell aeeclsid m_cls uint32 m_urefs brew and service interaction instance (cont .)
The upper BREW application calls iwms_msgread (aeewms. h) and belongs to the brew aee layer.
Iwms_msgread actually calls oemwms_msgread (oemwms. c) and belongs to the brew OEM layer.
In the oemwms_msgread function, call wms_msg_read (WMS. C, which belongs to the service layer) to send a cmd to wms_task. Wms_status_e_type wms_msg_read (invalid client_id, wms_rj_cb_type 1__cb, const void * user_data, invalid mem_store, wms_message_index_type index) brew interacts with the service instance (cont .)
{Wms_status_e_type ST = wms_ OK _s; wms_1__type * cmd_ptr; rows = wms_1__msg_read; rows = client_id; rows = cmd_cb; rows = (void *) user_data; bytes = mem_store;
Pai_backup.cmd.msg_read.index = index; // pai_backup value: pai_ptr = wms_get_cmd_buf (); // retrieve an element from the queue. Brew interacts with the service instance (cont.) If (pai_ptr! = NULL) {* cmd_ptr = cmd_backup; wms_put_cmd (cmd_ptr); // Insert the message to the queue and set the signal} else {wms_client_cmd_status (& cmd_backup, wms_cmd_err_no_resource );
// Callback error message ST = wms_out_of_resources_s;} return st;} brew and service interaction instance (cont .)
The execution environment of the preceding functions is ui_task. When wms_put_cmd is called, wms_task receives wms_0000_q_sig, and the corresponding environment converts wms_task.
After wms_task processing is completed, the app registers the callback function (to the app layer event) void wmsapp_cfgcb (uint16 event, wms_cfg * pinfo) {sms_cfg = malloc (sizeof (wms_cfg )); memcpy (sms_cfg, pinfo, sizeof (wms_cfg); ishell_posteven tex (pshell, evtflg_async, CLSID, event, sms_cfg);} brew interacts with the service instance (cont .)
The Brew receives the event (the execution environment is switched from wms_task to ui_task) and the brew interacts with the service instance (cont .) ui_task wms_task iwms_msgread oemwms_msgread wms_msg_read wait signal restart environment switch wms_msg_read_proc wms_msg_event_notify wmsapp_msgcb ishell_posteven Tex wmsapp_handleevent
Switch the environment to thanks!

Http://blog.csdn.net/tiger_ibm/article/details/5305048

Rex (Real-Time Executive) Rex
Rex is a real-time preemptible operating system.
Each Rex task is independently scheduled by the Rex kernel, each task has a Data Structure rex_tcb_struct.tcbs, which is arranged in a single linked list in order of priority-the active and suspended tasks are in the same list. each task will continue to execute to one of the following events and perform context switching.
Voluntarily suspend such as executing rex_wait or rex_timed_wiat
A signal is set in a high-priority pending task.
A task with a higher priority is generated.
An ongoing task has a higher priority than another task.
Interrupted tasks are generated and ISR switches to tasks with a higher priority than the interrupted tasks.
Rex allows tasks to have a priority ranging from 1 to 65535. 1 is the lowest priority. Priority 0 is reserved for idle tasks. No two or more tasks have the same priority. Rex Operating System
Task API: rex_def_task
Priority API: rex_set_pri, rex_task_pri, rex_get_pri.
Rex signal Working principle: the Rex signal is mainly concentrated in two fields of TCB:
SIGs: a mask that includes signals already set for a given task
Wait: a mask that includes some signals. Once these signals are set, the task is suspended.
Signal functions include: rex_wait (), rex_set_sigs (). rex_get_sigs (), rex_clr_sigs ()
Rex Timers: the active Rex timer is a two-way linked list with a rex_timer_struct structure. A rex_timer_struct is allocated for tasks that use the Rex timer, and then the rex_def_timer. rex_set_timer is called to start a timer.
Interrupt handling: The IRQ processor calls tramp_isr and then determines which interrupt is used to generate interaction between. Rex tasks.
Communication between tasks is completed through queues and semaphores.
Tasks that want to send messages to other tasks generate a global command queue and a message related to the queue.
Tasks that want to send messages to other tasks:
Gets the buffer of a command of the type related to the target task.
Fill in the appropriate area
Queue messages to the command queue
Set the interaction between relevant signal Rex tasks for this command (cont .)
Generally, queue operations and set signals are encapsulated into a function. Interaction between Rex tasks (cont .) task A Task B get cmd buffer from Task B and init put cmd buffer to Task B queue set signal for cmd wait signal process signal get cmd from queue and process it environment switch between Rex task and brew interaction
Method 1: The postevent method directly calls ishell_posteven Tex or ishell_postevent in a task of Rex. <Note 1> the main difference between ishell_posteven Tex and, this function allows you to pass multiple events of the same type (the same event Code) to the same Applet and queue events for distribution. Interaction between Rex task and BREW (cont.) <Note 2> If the last parameter of ishell_posteven Tex is a pointer, pay attention to the memory pointed to by the pointer. The memory allocated by calling different malloc or malloc in the high-end platform may come from different heaps. When releasing, the corresponding release function must be used. So we are calling
Before ishell_posteven Tex, copy the data and release the backup memory when the upper-layer app receives the message. Interaction between Rex task and BREW (cont .) the task a brew app calls the API of task a to register the callback function to call the callback function (the execution environment is task a). The callback function calls ishell_posteven Tex to receive the event and process it (the execution environment is aee) environment switching between Rex task and BREW (cont .)
Eg: void wmsapp_cfgcb (uint16 event, wms_cfg * pinfo)

{

Sms_cfg = malloc (sizeof (wms_cfg ));

Memcpy (sms_cfg, pinfo, sizeof (wms_cfg ));

Ishell_posteven tex (pshell, evtflg_async, CLSID, event, sms_cfg );

}

During initialization, wms_client_reg_msg_cb (ID, wmsapp_cfgcb) is called; Rex task interacts with BREW (cont .)
Method 2: use the same method. Call the aee_resumecallback method in the callback instead of the posteven Tex task a brew app to call the API of task a. register the callback function to call the callback function (the execution environment is task ), the callback function calls aee_resumecallback to receive the event and processes it (the execution environment is aee). The Brew and service interaction instance struct iwms {aeevtbl (iwms) * PVT; ishell * m_pishell; aeeclsid m_cls; // No use uint32 um_urefs;
// Reference count}; typedef struct {aeeapplet A; iwms * m_pwms ;... } Cwmsapp; ishell_createinstance (PME->. m_pishell, aeeclsid_wms, (void **) & PME-> m_pwms); // create the WMS interface. First, find the oemwms_new brew and service interaction instance (cont.) through goemstaticclasslist .) static const aeestaticclass goemstaticclasslist []
=={ Aeeclsid_wms, ascf_priv, 0, null, oemwms_new },};
Oemwms_new analysis (oemwms .) static struct iwms * iwmsobj = NULL; // local global variable int oemwms_new (ishell * pishell, aeeclsid CLs, void ** PPIF ){...; // parameter validity check if (iwmsobj = NULL) {If (iwmsobj = (iwms *) oem_malloc (sizeof (iwms) = NULL) {return enomemory ;} brew and service interaction instance (cont .)
Iwmsobj-> PVT = (iwmsvtbl *) & scheme; iwmsobj-> m_pishell = pishell; iwmsobj-> m_cls = CLS; iwmsobj-> m_urefs = 1; * PPIF = iwmsobj ;} else {(void *) oemwms_addref (iwmsobj); * PPIF = iwmsobj;} return aee_success} brew interacts with the service instance (cont .) static const aeevtbl (iwms)
Goemwmsfuncs = {oemwms_addref, oemwms_release, oemwms_queryinterface, oemwms_init,... oemwms_msgdeleteallext}; brew and service interaction instance (cont .)
# Define iwms_addref (P)/aeegetpvtbl (p, iwms)-> addref (p) to call iwms_addref is actually to call oemwms_addref oemwms_release oemwms_queryinterface oemwms_init... oemwms_msgdeleteallext aeevtbl (iwms) * PVT ishell * m_pishell aeeclsid m_cls uint32 m_urefs brew and service interaction instance (cont .)
The upper BREW application calls iwms_msgread (aeewms. h) and belongs to the brew aee layer.
Iwms_msgread actually calls oemwms_msgread (oemwms. c) and belongs to the brew OEM layer.
In the oemwms_msgread function, call wms_msg_read (WMS. C, which belongs to the service layer) to send a cmd to wms_task. Wms_status_e_type wms_msg_read (invalid client_id, wms_rj_cb_type 1__cb, const void * user_data, invalid mem_store, wms_message_index_type index) brew interacts with the service instance (cont .)
{Wms_status_e_type ST = wms_ OK _s; wms_1__type * cmd_ptr; rows = wms_1__msg_read; rows = client_id; rows = cmd_cb; rows = (void *) user_data; bytes = mem_store;
Pai_backup.cmd.msg_read.index = index; // pai_backup value: pai_ptr = wms_get_cmd_buf (); // retrieve an element from the queue. Brew interacts with the service instance (cont.) If (pai_ptr! = NULL) {* cmd_ptr = cmd_backup; wms_put_cmd (cmd_ptr); // Insert the message to the queue and set the signal} else {wms_client_cmd_status (& cmd_backup, wms_cmd_err_no_resource );
// Callback error message ST = wms_out_of_resources_s;} return st;} brew and service interaction instance (cont .)
The execution environment of the preceding functions is ui_task. When wms_put_cmd is called, wms_task receives wms_0000_q_sig, and the corresponding environment converts wms_task.
After wms_task processing is completed, the app registers the callback function (to the app layer event) void wmsapp_cfgcb (uint16 event, wms_cfg * pinfo) {sms_cfg = malloc (sizeof (wms_cfg )); memcpy (sms_cfg, pinfo, sizeof (wms_cfg); ishell_posteven tex (pshell, evtflg_async, CLSID, event, sms_cfg);} brew interacts with the service instance (cont .)
The Brew receives the event (the execution environment is switched from wms_task to ui_task) and the brew interacts with the service instance (cont .) ui_task wms_task iwms_msgread oemwms_msgread wms_msg_read wait signal restart environment switch wms_msg_read_proc wms_msg_event_notify wmsapp_msgcb ishell_posteven Tex wmsapp_handleevent
Switch the environment to thanks!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.