CN110955507A - Method for multi-task access grant IIC bus based on vxWorks system - Google Patents
Method for multi-task access grant IIC bus based on vxWorks system Download PDFInfo
- Publication number
- CN110955507A CN110955507A CN201911192484.3A CN201911192484A CN110955507A CN 110955507 A CN110955507 A CN 110955507A CN 201911192484 A CN201911192484 A CN 201911192484A CN 110955507 A CN110955507 A CN 110955507A
- Authority
- CN
- China
- Prior art keywords
- iic
- task
- access
- access request
- message
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4812—Task transfer initiation or dispatching by interrupt, e.g. masked
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2213/00—Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F2213/0016—Inter-integrated circuit (I2C)
Abstract
The invention discloses a method for granting IIC bus by multitask access based on vxWorks system, which comprises the steps of establishing a message queue based on priority, establishing an IIC access request processing task and establishing an IIC access request task; and executing the IIC access request processing task and the IIC access request task. The invention can be applied to the operation of adopting the VxWorks multitask access IIC bus of the IIC interface, and solves the problem that the task can not be operated or can not be operated completely. The stability of IIC access is greatly improved, the integrity of data and the integrity of functions are guaranteed, and the reliability of products is enhanced. The method has the advantages that the software framework is clear, the request formation and processing are effectively separated, the thought is clear, and the portability of the method is enhanced.
Description
Technical Field
The invention relates to a method for granting IIC bus by multitask access based on vxWorks system, belonging to the technical field of task access optimization in embedded system.
Background
At present, due to the limitation of the number of IIC buses, many embedded products often use the same IIC bus to mount different devices, such as an EEPROM, an ADC, and the like, and generally divide the devices into different tasks according to the functions of the devices, for example, the work of accessing the EEPROM is divided into a task of processing a fault and storing the fault, and the work of accessing the ADC is divided into a task of acquiring data. The requests to access the IIC may be triggered simultaneously or at short intervals.
The vxWorks system schedules tasks based on priority, so that simultaneous access or preemptive access can be caused, requests of partial tasks cannot be operated or cannot be operated completely, and data loss and function loss and incompleteness are caused. Even if synchronization, mutual exclusion, or the like between tasks is added, waiting of tasks that do not acquire the IIC bus access right is caused, and other processing of these tasks is affected.
Disclosure of Invention
The invention aims to solve the defects of the prior art, and provides a vxWorks system-based method for granting IIC bus by multi-task access, aiming at the problem that partial task requests cannot be operated or cannot be operated completely due to the fact that preemptive access is easy to occur in the traditional multi-task access.
In order to achieve the purpose, the technical scheme adopted by the invention is as follows:
the method for granting the IIC bus by multitask access based on the vxWorks system comprises the following steps:
step one, message task and task creation,
creating a message queue based on priority, creating an IIC access request processing task and creating an IIC access request task;
step two, the IIC accesses the operation of the request processing task,
after an IIC access request processing task is established, periodically inquiring and receiving messages in a message queue, analyzing the messages, obtaining at least IIC addresses, read-write types and register address information, shielding task preemption and interruption, calling an IIC access interface, enabling the tasks to be preempted and interrupted, and finally waiting for fixed time;
step three, the IIC access request task is operated,
and after an IIC access request task is created, checking whether an IIC bus needs to be accessed or not, if so, assembling IIC address, read-write type and register address information into IIC access request information according to the priority of the current task, calling a message sending interface, sending the request information to a message queue, and if not, carrying out other processing, wherein the message queue can sort the request information according to the priority in a low-priority order.
Preferably, in the first step, the message queue is created before the IIC access request processing task and the IIC access request task.
Preferably, the first step includes:
202, creating a message queue based on priority, wherein the message content of the message queue comprises a read-write type, an IIC address and a register type;
in step 206, the task having the IIC access request is run.
Preferably, the second step includes:
Preferably, the third step includes:
step 401: other task processing than message queues;
step 402: checking that there is an IIC access request;
step 403: if an IIC access request exists, then step 404 is executed; otherwise, operating step 401;
step 404: assembling request information including but not limited to IIC address, read-write type, register address;
step 405: and calling a message sending interface according to the priority of the task, and sending the information to a message queue.
The invention has the following beneficial effects:
1. the method can be applied to the operation of adopting the IIC interface vxWorks to access the IIC bus in a multi-task mode, and the problem that the task cannot be operated or cannot be operated completely is solved.
2. The stability of IIC access is greatly improved, the integrity of data and the integrity of functions are guaranteed, and the reliability of products is enhanced.
3. The method has the advantages that the software framework is clear, the request formation and processing are effectively separated, the thought is clear, and the portability of the method is enhanced.
Drawings
FIG. 1 is a logic framework diagram of the method for granting the IIC bus based on the multitask access of the vxWorks system.
FIG. 2 is a flow chart of the method for granting the IIC bus based on the multitask access of the vxWorks system.
Fig. 3 is a flowchart illustrating the operation of the IIC access request processing task in the present invention.
Fig. 4 is a flowchart illustrating the operation of the IIC access request task in the present invention.
Detailed Description
The invention provides a method for granting IIC bus by multitask access based on vxWorks system. The technical solution of the present invention is described in detail below with reference to the accompanying drawings so that it can be more easily understood and appreciated.
Referring to fig. 1, the process involved in the present invention is divided into three parts, i.e., a message queue, an IIC access request processing task and an IIC access request task, wherein the IIC access request processing task operates the message queue according to a priority order, and the IIC access request task receives messages from the message queue. The three-part processing sequence exists as an inherent logical sequence as shown in fig. 1.
With reference to fig. 2 to 4, the apparatus using the present invention operates with the following steps:
The creation of the message queue needs to be performed before the creation of the task of transmitting the IIC access request and the task of processing the IIC access request. Because the tasks related to the invention all process the message queue, the creation time of the message queue can ensure that the tasks for processing the message queue do not have errors.
The created message queue is a queue based on priority under vxWorks, and can queue the sent messages according to the priority of the current task of the calling message sending interface, wherein the higher the priority is, the faster the messages reach the receiving end. And under the condition of the same priority, the earlier the transmission is, the faster the transmission reaches the receiving end.
The message queue can accommodate a number of messages of a capacity greater than the number of all tasks containing IIC access requests. The information stored in the message queue includes, but is not limited to, IIC address, read-write type, register address, and the like. Part of the information is used as an input parameter for the IIC access interface.
In step 204, the IIC accesses the operation of the task requested to process, and after the task is operated, step 301 is executed.
In step 205, a task having an IIC access request is created, and several tasks are created if several tasks need to access the IIC.
In step 206, the task having the IIC access request is executed, and after the task is executed, step 401 is executed.
And step 304, shielding task preemption, shielding preemption of a high-priority task, ensuring that the task is not preempted by other tasks when the step 306 is operated, and ensuring the integrity of IIC access.
And 307, enabling interruption to ensure that the interruption can work normally.
And 308, enabling the task to preempt, and recovering the task to preempt so as not to influence the running of other tasks.
The waiting fixed time is integral multiple of the minimum scheduling time of one task, the determination of the time needs to be based on the processing time of the task with lower priority, so that the task with lower priority than the IIC request processing task can be fully operated, and the time requirement of the IIC access request needs to be considered and needs to be determined according to specific application occasions.
at step 402, the IIC access request is checked to see if a request for IIC access has been triggered.
At step 404, request information is assembled, including but not limited to IIC address, read and write type, register address, etc.
Through the above description, it can be found that the method for granting the IIC bus based on the multi-task access of the vxWorks system can be applied to the operation of the vxWorks with the IIC interface for multi-task access of the IIC bus, and the problem that the task cannot be operated or cannot be operated completely is solved. The stability of IIC access is greatly improved, the integrity of data and the integrity of functions are guaranteed, and the reliability of products is enhanced. The method has the advantages that the software framework is clear, the request formation and processing are effectively separated, the thought is clear, and the portability of the method is enhanced.
The technical solutions of the present invention are fully described above, it should be noted that the specific embodiments of the present invention are not limited by the above description, and all technical solutions formed by equivalent or equivalent changes in structure, method, or function according to the spirit of the present invention by those skilled in the art are within the scope of the present invention.
Claims (5)
1. The method for granting the IIC bus by multitask access based on the vxWorks system is characterized by comprising the following steps of:
step one, message task and task creation,
creating a message queue based on priority, creating an IIC access request processing task and creating an IIC access request task;
step two, the IIC accesses the operation of the request processing task,
after an IIC access request processing task is established, periodically inquiring and receiving messages in a message queue, analyzing the messages, obtaining at least IIC addresses, read-write types and register address information, shielding task preemption and interruption, calling an IIC access interface, enabling the tasks to be preempted and interrupted, and finally waiting for fixed time;
step three, the IIC access request task is operated,
and after an IIC access request task is created, checking whether an IIC bus needs to be accessed or not, if so, assembling IIC address, read-write type and register address information into IIC access request information according to the priority of the current task, calling a message sending interface, sending the request information to a message queue, and if not, carrying out other processing, wherein the message queue can sort the request information according to the priority in a low-priority order.
2. The vxWorks system based method for multi-tasking access grant IIC bus as claimed in claim 1, wherein:
in the first step, the message queue is created before the IIC access request processing task and the IIC access request task.
3. The vxWorks system based multitask access grant IIC bus method according to claim 1 wherein said first step comprises:
step 201, powering on equipment and running a program;
202, creating a message queue based on priority, wherein the message content of the message queue comprises a read-write type, an IIC address and a register type;
step 203, the creation of an IIC access request processing task, which is used for processing IIC request information and accessing;
step 204, the IIC accesses the running of the request processing task;
step 205, the IIC access request task is created, and a plurality of tasks are created;
in step 206, the task having the IIC access request is run.
4. The vxWorks system based multitask access grant IIC bus method according to claim 1 wherein said step two includes:
step 301, monitoring a message queue, and checking whether a new message is generated;
step 302, when a new message is generated, step 303 is executed, otherwise, step 309 is executed;
step 303, analyzing the message, and acquiring the IIC address, the read-write type and the register address information from the message;
step 304, shielding task preemption, shielding high priority task preemption, and ensuring that the task is not preempted by other tasks when the step 306 runs;
step 305, shielding the interrupt, and ensuring that the operation of the step 306 is not interrupted by the interrupt;
step 306, calling an IIC access interface for accessing the IIC bus;
step 307, enabling interruption to ensure that the interruption can work normally;
step 308, enabling task preemption and recovering task preemption so as not to influence the operation of other tasks;
step 309, wait for a fixed time for the other lower priority tasks to run.
5. The vxWorks system based multitask access grant IIC bus method according to claim 1 wherein said third step comprises:
step 401: other task processing than message queues;
step 402: checking that there is an IIC access request;
step 403: if an IIC access request exists, then step 404 is executed; otherwise, operating step 401;
step 404: assembling request information including but not limited to IIC address, read-write type, register address;
step 405: and calling a message sending interface according to the priority of the task, and sending the information to a message queue.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911192484.3A CN110955507B (en) | 2019-11-28 | 2019-11-28 | Method for multitask access to same IIC bus based on vxWorks system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911192484.3A CN110955507B (en) | 2019-11-28 | 2019-11-28 | Method for multitask access to same IIC bus based on vxWorks system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110955507A true CN110955507A (en) | 2020-04-03 |
CN110955507B CN110955507B (en) | 2022-10-21 |
Family
ID=69978727
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911192484.3A Active CN110955507B (en) | 2019-11-28 | 2019-11-28 | Method for multitask access to same IIC bus based on vxWorks system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110955507B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1744046A (en) * | 2004-08-31 | 2006-03-08 | 华为技术有限公司 | Multi-task application software module management method in real-time operating system environment |
CN110083473A (en) * | 2019-04-16 | 2019-08-02 | 芯来智融半导体科技(上海)有限公司 | Improvement system and method based on RISC-V framework bus access mistake |
-
2019
- 2019-11-28 CN CN201911192484.3A patent/CN110955507B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1744046A (en) * | 2004-08-31 | 2006-03-08 | 华为技术有限公司 | Multi-task application software module management method in real-time operating system environment |
CN110083473A (en) * | 2019-04-16 | 2019-08-02 | 芯来智融半导体科技(上海)有限公司 | Improvement system and method based on RISC-V framework bus access mistake |
Also Published As
Publication number | Publication date |
---|---|
CN110955507B (en) | 2022-10-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9092356B2 (en) | Executing a kernel device driver as a user space process | |
US8756613B2 (en) | Scalable, parallel processing of messages while enforcing custom sequencing criteria | |
CN107341062B (en) | Data pushing method, device, equipment and storage medium | |
CN113366457A (en) | Handling input/output store instructions | |
CN114168271B (en) | Task scheduling method, electronic device and storage medium | |
JPS63128457A (en) | Controller and control of access to input/output device | |
CN111897637A (en) | Job scheduling method, device, host and storage medium | |
CN113366438A (en) | Handling input/output store instructions | |
CN113535425A (en) | Data sending method and device, electronic equipment and storage medium | |
JP2015530679A (en) | Method and apparatus using high efficiency atomic operations | |
EP0287295A2 (en) | Multiple I/O bus virtual broadcast of programmed I/O instructions | |
US8141077B2 (en) | System, method and medium for providing asynchronous input and output with less system calls to and from an operating system | |
CN114461365A (en) | Process scheduling processing method, device, equipment and storage medium | |
US9229716B2 (en) | Time-based task priority boost management using boost register values | |
CN111831408A (en) | Asynchronous task processing method and device, electronic equipment and medium | |
CN110955507B (en) | Method for multitask access to same IIC bus based on vxWorks system | |
JPH05250337A (en) | Multiprocessor system having microprogram means for dispatching processing to processor | |
CN114416317B (en) | Inter-core interrupt execution method, inter-core interrupt processing device, inter-core interrupt equipment and storage medium | |
US6675238B1 (en) | Each of a plurality of descriptors having a completion indicator and being stored in a cache memory of an input/output processor | |
CN115499493A (en) | Asynchronous transaction processing method and device, storage medium and computer equipment | |
US9563494B2 (en) | Systems and methods for managing task watchdog status register entries | |
CN106484536B (en) | IO scheduling method, device and equipment | |
CN117093335A (en) | Task scheduling method and device for distributed storage system | |
JP2002312302A (en) | Peripheral device | |
CN115858118A (en) | Distributed task scheduling method, system, device and medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |