Page 398 - ARM Based Microcontroller Projects Using MBED
P. 398
384 15. Mbed RTOS PROJECTS
FIG. 15.6, CONT’D
FIG. 15.17 Typical display from the program.
A typical display from the program is shown in Fig. 15.17.
15.8 Mbed QUEUE AND MEMORYPOOL
Queues allow the user to queue pointers to data from producer threads to consumer
threads. The Mbed queue functions are queue.put() to put into the queue and queue.get()
to get from a queue. Fig. 15.18 shows a basic queue operation. A queue is created using
the keyword Queue.
MemoryPool is used to manage fixed-size memory pools. The Mbed memory pool function
alloc() is used to allocate a fixed amount of memory to the thread. Function free() returns the
allocated memory block.
An example combined queue and memory pool program (program: queue) is shown in
Fig. 15.19. In this program a structure called msg is created with two integer variables no1