8/20/2019 Freertos Syncronize Two Task
Simple project to demonstrate the FreeRTOS+Trace and FreeRTOS+CLI products The FreeRTOS Ecosystem Showcase. A Selection of Add-on and Complementary Products. FreeRTOS: Programming for Real Time Operating Systems FreeRTOS is a cross platform real-time operating system (RTOS) kernel for embedded devices such as microcontrollers and small microprocessors. In this instru.
My problem is that I have two async tasks which doing a kind of matrix multiplications. Therefore both tasks are accessing the same matrix. One the upper part, the other the lower part. For memory saving issues I use ArrayLists and delete entries which I do not need longer. The problem is that in both tasks there is for loop runing and at the end of this loop it should wait for the other task. But I do not know how to do this.Task 1:
Task 2:
I tried to use notify and wait, but it seems that this is not solving the issue. I do not know any additional methods which I could use to solve the issue. Is it actually possible to wait two for the other task while both are running?
Irgendw PointerIrgendw Pointer
2 Answers
If this is Java-7 you are looking for a Phaser. The method you need is arriveAndAwaitAdvance.
In earlier versions of Java (5.1 or later) you would probably use a Semaphore.
Alternatively - you could switch to using a thread pool such as an ExecutorService and Futures. This would be much more scalable and take better advantage of the a multi-core processor.
OldCurmudgeonOldCurmudgeon
I believe the answer to questions below can provide you about the abstract information on how to manage multiple Async tasks.
and github example:
https://github.com/vitkhudenko/test_asynctask (credits to: vitkhudenko)
Community♦
JeremyJeremy
Not the answer you're looking for? Browse other questions tagged javaandroidmultithreadingasynchronousandroid-asynctask or ask your own question.
Roland Rabien - 2013-02-25
Hi,
I'm new to FreeRTOS and I'm trying to get what I think is a fairly simple project going, and I'm having problems with tasks blocking indefinitely on xSemaphoreTake. I'm using a Atmel Sam3u4e with Atmel Studio 6 SP2 and FreeRTOS 7.3.0 that ships with the Atmel Software Framework 3.5.1.
I have reduced my program to the minimal parts to reproduce the problem. I have two tasks, loggertask and systask. loggertask is woken by one of three data ready interrupts, and then uses spi to read from either a accelerometer, gyro or magnetometer. systask does nothing but wait on a semaphore that is never given.
I create loggertask from systask like this:
The main loop looks like this:
And my interrupts look like:
As for my systask, it is very simple, I create it like this:
And it's loop looks like this:
The systask_service_logger function creates the loggertask 1 second after the system starts and does nothing else. Future plans are for the systask will take data from the loggertask and write it to an sdcard.
After approximation 10 minutes of runtime, the loggertask hangs on xSemaphoreTake(). The interrupts are still firing, but the call to xSemaphoreGiveFromISR() fails with a errQUEUE_FULL. systask is still running. No breakpoints I set in loggertask ever get hit. FreeRTOS Viewer lists the logger task as Ready with a top of stack 0x2007eea0 and start of stack 0x2007df38. IDLE is running and sys and Tmr Svc are blocked. Removing the calls to read the accelerometer, gyro, magnetometer does not solve the problem, so I loggertask must be getting stuck in xSemaphoreTake().
Is there any way to force a context switch to loggertask so I can examine it's callstack? Where do I look to see if loggertask->sync is corrupted.
My program is very simple, so I must be doing something fairly basic incorrectly. Can anybody see what it is?
Thanks,
Roland Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |