Page 1 of 1

Multithreading in RPI 3 64 bit

Posted: Fri Apr 13, 2018 4:42 pm
by btauro
Hi,

For Now I have all cores parked using WFI how do i wakeup these cores .I am using 64 bit for the bare metal os.

I want to implement threads on The RPI3 Bare OS.So i have looked through the ldrex,strexeq .

Apart from the exclusive access are there any hardware support available for threads in RPI3 ARM v8 .

What are the other factors to be considered in RPi 3 concerning thread implementation in RPi3.



Thanks,

Re: Multithreading in RPI 3 64 bit

Posted: Sat Apr 14, 2018 2:36 am
by Ultibo
btauro wrote:
Fri Apr 13, 2018 4:42 pm
For Now I have all cores parked using WFI how do i wakeup these cores .I am using 64 bit for the bare metal os.

I want to implement threads on The RPI3 Bare OS.So i have looked through the ldrex,strexeq .

Apart from the exclusive access are there any hardware support available for threads in RPI3 ARM v8 .

What are the other factors to be considered in RPi 3 concerning thread implementation in RPi3.
There is quite a lot of information and examples I could point you to but first you should probably clarify if you want to do actual multi-threading (with multiple threads per CPU) or if you just want to run a single task per core.

If you only want to run one task per core then you can find examples in the posts in this forum that demonstrate some basic solutions for that and the rest of the information below won't be relevant.

If you want to do real multi-threading then you need to decide if you want to do cooperative or preemptive threading, cooperative is simpler but preemptive can be more powerful. You should also leave the other cores parked for now and get threading working on a single CPU, once you have that right then multiple CPUs will be much easier to implement.

Either way you will need code to perform a context switch, some sort of thread queue and a way to create new threads each with their own stack etc. For preemptive threading you''ll also need a timer interrupt to drive the scheduler.

And yes the ARM does have a small amount of hardware support for threading, in particular the ability to ask for the current CPU number and also to store a unique ID (like a thread ID) in one of the control registers so you can access it quickly during interrupts and in context switch etc.