CN104598208B - A kind of operating system of single-chip microcomputer implementation method of Effect-based operation queue - Google Patents
A kind of operating system of single-chip microcomputer implementation method of Effect-based operation queue Download PDFInfo
- Publication number
- CN104598208B CN104598208B CN201510071580.8A CN201510071580A CN104598208B CN 104598208 B CN104598208 B CN 104598208B CN 201510071580 A CN201510071580 A CN 201510071580A CN 104598208 B CN104598208 B CN 104598208B
- Authority
- CN
- China
- Prior art keywords
- message
- queue
- stored
- function
- pointer
- 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.)
- Active
Links
Landscapes
- Devices For Executing Special Programs (AREA)
Abstract
The invention discloses a kind of operating system of single-chip microcomputer implementation method of Effect-based operation queue, adopt C language coding code, use the compiler of Keil company to carry out compiling and generate scale-of-two execute file, the method first defines the array of message structure type and message structure type as message queue; Then the first in first out function that message access function realizes message queue is devised; Last principal function infinite loop reads message, and calls corresponding task process function according to message value, circulates after task process function returns next time.The invention has the beneficial effects as follows: in this scm software system, first stored in message be first performed, achieve the function of Preemptive multitask operating system, make the code structure write succinct, well arranged and easily safeguard, software operation efficiency significantly improves.
Description
Technical field
The present invention relates to a kind of operating system of single-chip microcomputer implementation method of Effect-based operation queue.
Background technology
As everyone knows, the program's memory space of single-chip microcomputer is all relative with data space deficient, and 51 series monolithic program addressable spaces of standard model and addressing data space all only have 64KB, and clock frequency is mostly lower than 100MHz.If by existing popular embedded OS transplant in single-chip microcomputer, the ROM space of tens of a few KB will be taken easily, the advantage of real-time also without.Therefore be necessary that the Software for Design one for single-chip microcomputer takes up room little, the operating system that operational efficiency is high.
Summary of the invention
The object of the invention is to overcome the deficiencies in the prior art, a kind of operating system of single-chip microcomputer implementation method of Effect-based operation queue is provided, realizes the multitask running of software, make software configuration succinct, well arranged, run more efficient, take up room less.
The object of the invention is to be achieved through the following technical solutions: a kind of operating system of single-chip microcomputer implementation method of Effect-based operation queue, it adopts C language coding code, use the compiler of Keil to carry out compiling and generate scale-of-two execute file, it comprises the following steps:
S1: definition message structure type, comprises message word, parameter A and parameter B;
S2: definition message queue, first according to memory source and the task disposition definition message queue length of chip, then define a data type be the array of message structure as message queue, for storing message and parameter;
S3: the access indicator of definition message queue, is all set to zero by access indicator during initialization, be used to indicate message stored in position in message queue when reading, when stored in time identical with reading pointer, represent there is no message;
S4: send a message to message queue, comprises following sub-step:
S41: according to message stored in the position indicated by pointer by message stored in message queue, stored in pointer increment;
S42: judge whether reach maximal value stored in pointer, if then will be set to zero stored in pointer;
S43: judge whether message queue is filled with, if then mean that untreated message will be capped, thus generation systems staging error, then carry out system reset to avoid system cloud gray model mistake;
S5: read message and parameter from message queue, comprises following sub-step:
S51: chip watchdog zero clearing;
S52: judge whether to need processing messages, if need processing messages, carries out step S53, if do not have pending message, returns step S51;
S53: read message according to the position indicated by message reading pointer from message array, reading pointer increment;
S54: judge whether reading pointer is maximal value, if then reading pointer is set to zero, if not then end operation;
S6: message is read in principal function circulation, after reading message and parameter, calls corresponding task process function, circulate after task process terminates next time again according to message value.
Step S1, S2 and S3, define the data structure of message queue, comprises message structure data type, message queue array and message queue access indicator; The array constituent element quantity of message queue sets according to the task amount of single-chip microcomputer hardware resource, clock frequency and process.
Step S4, use function realize message stored in, with ensure at first stored in message can be read at first.This function is called, for notifying that corresponding task process function performs corresponding task program by interrupt service routine and task processor.
Step S5, uses function to realize the reading of message, with ensure at first stored in message can be read at first.This function is called, for obtaining message from message queue by principal function.
Step S6, the principal function infinite loop of being write by C language reads the message of message queue, then calls corresponding task process function, handling procedure of executing the task according to the message value read, circulates to read message after task process function returns next time.
The invention has the beneficial effects as follows: in this scm software system, first stored in message be first performed, achieve the function of Preemptive multitask operating system; Use the present invention to design scm software task, each mission function only performs corresponding program after receiving corresponding message, returns after complete, and this task of other times is in halted state, now can perform other tasks.When designing scm software system, multiple task process function can be designed to complete different task, also the task of complexity can be divided into multiple level.Achieve the multitask running of scm software, make the code structure write succinct, well arranged and easily safeguard, software operation efficiency significantly improves.
Accompanying drawing explanation
Fig. 1 is that the present invention is stored in message flow chart;
Fig. 2 is that the present invention reads message flow chart;
Fig. 3 is principal function process flow diagram of the present invention.
Embodiment
Below in conjunction with accompanying drawing, technical scheme of the present invention is described in further detail, but protection scope of the present invention is not limited to the following stated.
An operating system of single-chip microcomputer implementation method for Effect-based operation queue, it adopts C language coding code, and use the compiler of Keil company to carry out compiling and generate scale-of-two execute file, its kernel code comprises following content and step:
S1: definition message structure type, comprises message word, parameter A and parameter B;
S2: definition message queue, first according to memory source and the task disposition definition message queue length of chip, then define a data type be the array of message structure as message queue, for storing message and parameter;
S3: the access indicator of definition message queue, is all set to zero by access indicator during initialization, be used to indicate message stored in position in message queue when reading, when stored in time identical with reading pointer, represent there is no message;
S4: send a message to message queue, as shown in Figure 1, it comprises following sub-step to function program flow process:
S41: according to message stored in the position indicated by pointer by message stored in message queue, stored in pointer increment;
S42: judge whether reach maximal value stored in pointer, if then will be set to zero stored in pointer;
S43: judge whether message queue is filled with, if then mean that untreated message will be capped, thus generation systems staging error, then carry out system reset to avoid system cloud gray model mistake;
S5: read message and parameter from message queue, the program circuit of function as shown in Figure 2, comprises following sub-step:
S51: chip watchdog zero clearing;
S52: judge whether to need processing messages, if need processing messages, carries out step S53, if do not have pending message, returns step S51;
S53: read message according to the position indicated by message reading pointer from message array, reading pointer increment;
S54: judge whether reading pointer is maximal value, if then reading pointer is set to zero, if not then end operation;
S6: message is read in principal function circulation, and function program flow process as shown in Figure 3, after reading message and parameter, is called corresponding task process function according to message value, circulated after task process terminates next time again.
Step S1, S2 and S3, define the data structure of message queue, comprises message structure data type, message queue array and message queue access indicator.The array constituent element quantity of message queue sets according to the task amount of single-chip microcomputer hardware resource, clock frequency and process.
Step S4, use function realize message stored in, with ensure at first stored in message can be read at first.This function is called, for notifying that corresponding task process function performs corresponding task program by interrupt service routine and task processor.
Step S5, uses function to realize the reading of message, with ensure at first stored in message can be read at first.This function is called, for obtaining message from message queue by principal function.
Step S6, the principal function infinite loop of being write by C language reads the message of message queue, then calls corresponding task process function, handling procedure of executing the task according to the message value read, circulates to read message after task process function returns next time.
The present invention adopt single-chip microcomputer model be C8051F340, this type single-chip microcomputer employs standard 8051 single-chip microcomputer kernel, and carry out on this basis extend part peripheral functionality.Use C language coding code in the present invention, use the compiler of Keil company to carry out compiling and generate scale-of-two execute file.The core of its operating system of single-chip microcomputer is message queue.Message queue is a first in first out array, and data type is message structure type.Message structure includes message word, parameter A and parameter B.Realize with function (SendMsg) stored in message, read message with function (GetMsg) ensure first stored in message be first read.
Single-chip microcomputer is automatic operational system principal function after the power-up, and principal function is the entrance that scm software runs.In function, first perform the hardware initialization of single-chip microcomputer, as timer initialization, serial ports initialization and interrupt system initialization etc.; Then define the data structure of message queue, comprise message structure data type, message queue array and message queue access indicator.The array constituent element quantity of message queue sets according to the task amount of single-chip microcomputer hardware resource, clock frequency and process; Define the access indicator of message queue again, be used to indicate message stored in position in message queue when reading, when stored in time identical with reading pointer, represent there is no message; Last initial message queue, is set to zero by message stored in pointer and reading pointer; Run principal function, principal function starts the message that infinite loop reads fifo queue, after reading message returns, calls corresponding process according to News Category, circulates again next time read message and call corresponding process after process process returns.First stored in message be first performed, to realize the function that Preemptive multitask runs simultaneously.
When principal function calls each process function, can by message and Parameter transfer to process, process responds for message.Must exit after process has responded.Mode by sending message between each process carries out communication with synchronous.
Claims (5)
1. an operating system of single-chip microcomputer implementation method for Effect-based operation queue, it adopts C language coding code, uses the compiler of Keil company to carry out compiling and generates scale-of-two execute file, it is characterized in that: it comprises the following steps:
S1: definition message structure data type, comprises message word;
S2: definition message queue, first according to memory source and the task disposition definition message queue length of chip, then define a data type be the array of message structure as message queue, for storing message and parameter;
S3: definition message queue stored in pointer and reading pointer, all will be set to zero stored in pointer and reading pointer during initialization, be used to indicate message stored in position in message queue when reading, when identical with reading pointer stored in pointer, represent there is no message;
S4: send a message to message queue, comprises following sub-step:
S41: according to message stored in the position indicated by pointer by message stored in message queue, stored in pointer increment;
S42: judge whether reach maximal value stored in pointer, if then will be set to zero stored in pointer;
S43: judge whether message queue is filled with, if then mean that untreated message will be capped, thus generation systems staging error, then carry out system reset to avoid system cloud gray model mistake;
S5: read message and parameter from message queue, comprises following sub-step:
S51: chip watchdog zero clearing;
S52: judge whether to need processing messages, if need processing messages, carries out step S53, if do not have pending message, returns step S51;
S53: read message according to the position indicated by message reading pointer from message array, reading pointer increment;
S54: judge whether reading pointer is maximal value, if then reading pointer is set to zero, if not then end operation;
S6: message is read in principal function circulation, after reading message and parameter, calls corresponding task process function, circulate after task process terminates next time again according to message value.
2. the operating system of single-chip microcomputer implementation method of a kind of Effect-based operation queue according to claim 1, it is characterized in that: described step S1, S2 and S3, define the data structure of message queue, comprise message structure data type, message queue array, message queue stored in pointer and reading pointer, the array constituent element quantity of described message queue sets according to the task amount of single-chip microcomputer hardware resource, clock frequency and process.
3. the operating system of single-chip microcomputer implementation method of a kind of Effect-based operation queue according to claim 1, it is characterized in that: described step S4, use function realize message stored in, with ensure at first stored in message can be read at first, this function is called, for notifying that corresponding task process function performs corresponding task program by interrupt service routine and task processor.
4. the operating system of single-chip microcomputer implementation method of a kind of Effect-based operation queue according to claim 1, it is characterized in that: described step S5, function is used to realize the reading of message, with ensure at first stored in message can be read at first, this function is called, for obtaining message from message queue by principal function.
5. the operating system of single-chip microcomputer implementation method of a kind of Effect-based operation queue according to claim 1, it is characterized in that: described step S6, the principal function infinite loop of being write by C language reads the message of message queue, then corresponding task process function is called according to the message value read, to execute the task handling procedure, circulate to read message after task process function returns next time.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510071580.8A CN104598208B (en) | 2015-02-11 | 2015-02-11 | A kind of operating system of single-chip microcomputer implementation method of Effect-based operation queue |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510071580.8A CN104598208B (en) | 2015-02-11 | 2015-02-11 | A kind of operating system of single-chip microcomputer implementation method of Effect-based operation queue |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104598208A CN104598208A (en) | 2015-05-06 |
CN104598208B true CN104598208B (en) | 2016-01-27 |
Family
ID=53124031
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510071580.8A Active CN104598208B (en) | 2015-02-11 | 2015-02-11 | A kind of operating system of single-chip microcomputer implementation method of Effect-based operation queue |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104598208B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108021448B (en) * | 2017-11-30 | 2021-06-15 | 北京东土科技股份有限公司 | Kernel space optimization method and device |
CN109324885A (en) * | 2018-09-13 | 2019-02-12 | 厦门拓宝科技有限公司 | A kind of multitask management process applied to the monolithic processor controlled minimum operation system of UPS and based on minimum operation system |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102880507A (en) * | 2012-09-12 | 2013-01-16 | 科立讯通信股份有限公司 | Method for applying and distributing chain structure message |
CN103440171A (en) * | 2013-08-25 | 2013-12-11 | 浙江大学 | Realization method of real-time operating system of component-based hardware |
CN103543988A (en) * | 2013-10-23 | 2014-01-29 | 华为终端有限公司 | Method for processing array information, method and device of controlling information to enter arrays |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8194657B2 (en) * | 2007-05-22 | 2012-06-05 | Actiontec Electronics, Inc. | Systems and methods for dynamic quality of service |
-
2015
- 2015-02-11 CN CN201510071580.8A patent/CN104598208B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102880507A (en) * | 2012-09-12 | 2013-01-16 | 科立讯通信股份有限公司 | Method for applying and distributing chain structure message |
CN103440171A (en) * | 2013-08-25 | 2013-12-11 | 浙江大学 | Realization method of real-time operating system of component-based hardware |
CN103543988A (en) * | 2013-10-23 | 2014-01-29 | 华为终端有限公司 | Method for processing array information, method and device of controlling information to enter arrays |
Also Published As
Publication number | Publication date |
---|---|
CN104598208A (en) | 2015-05-06 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN1890640B (en) | Efficient system management synchronization and memory allocation | |
CN107526645B (en) | A kind of communication optimization method and system | |
CN106681949B (en) | Direct memory operation implementation method based on consistency acceleration interface | |
CN107992370B (en) | VxWorks platform multitask software framework implementation method | |
CN109858621B (en) | Debugging device and method of convolutional neural network accelerator and storage medium | |
CN109240966A (en) | A kind of accelerator card based on CPLD, collecting method and device | |
CN103019838A (en) | Multi-DSP (Digital Signal Processor) platform based distributed type real-time multiple task operating system | |
CN104598208B (en) | A kind of operating system of single-chip microcomputer implementation method of Effect-based operation queue | |
CN104683472A (en) | Data transmission method capable of supporting large data volume | |
CN104932933A (en) | Spin lock acquisition method and apparatus | |
CN104320317A (en) | Method and device for transmitting state of Ethernet physical layer chip | |
CN109507991B (en) | Double-shaft servo control platform debugging system and method | |
CN104850516A (en) | DDR frequency conversion design method and device | |
CN111475312A (en) | Message driving method and device based on real-time operating system | |
CN110968352A (en) | PCIE equipment resetting system and server system | |
CN101373444A (en) | Exposing system topology to the execution environment | |
CN106886477B (en) | Method and device for setting monitoring threshold in cloud system | |
CN110532150B (en) | Case management method and device, storage medium and processor | |
CN112162822A (en) | Mirror image construction method, device, equipment and readable storage medium | |
Bertolotti et al. | Modular design of an open-source, networked embedded system | |
US11360702B2 (en) | Controller event queues | |
CN111443898A (en) | Method for designing flow program control software based on priority queue and finite-state machine | |
CN109582379A (en) | Programmable logic controller system, control method based on Mach | |
CN108075989B (en) | Extensible protocol-based load balancing network middleware implementation method | |
CN104102491A (en) | Implementation method and system for parallel execution of real-time task and time-consuming task of single chip microcomputer |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant |