Posts: 1
Joined: Fri Jun 18, 2021 12:11 pm

controlling the processor and core allocation

Fri Jun 18, 2021 12:24 pm

I'm trying to write a C program that will be able to use the HQ raspberry pi camera to take a picture when a GPIO lit goes from high to low or vice verso.

The standard kernel build of raspbian give all 4 cores of the raspberry pi. What I would like to do is limit the cores the operating system can use to two and leave one to constantly check the GPIO and the other to tell the camera to take a still image.

I have worked out how to build a kernel that only initialise two of the four cores but I not sure that is the way to go.

I know that this is at the black belt end of the programming and operating system manipulation. I know there are far brighter folks than I on this forum, that could probable do this in their sleep. I'm better at the hardware side of things.

I know to get the speed I will need to address the memory location for the GPIO and CSI directly without libraries, this is kind of scary stuff.

Anything I learn I am happy to share.

Posts: 39
Joined: Mon May 24, 2021 8:03 am

Re: controlling the processor and core allocation

Sun Jun 20, 2021 7:12 pm

tasksel can be used to set cpu affinity per process (thread). Maybe if you hacked your init process to use only two cpus, all subsequent processes would inherit that setting. Then your two specific ones could be set to one other cpu each.

Not sure how to limit the kernel itself. Is limiting cpu affinity of kernel threads sufficient (or possible) ?

User avatar
Posts: 5852
Joined: Wed Aug 28, 2013 3:31 am

Re: controlling the processor and core allocation

Mon Jun 21, 2021 3:45 am

Libcamera/Libcamera apps/Raspiraw are the places I am starting with.
Those are ARM side based, Raspistill/Vid are VC side and mostly hidden.

Hopefully I or someone better at coding can get ARM side camera stuff working on Ultibo. ... 1-MultiCPU ... V/RaspiCam

With Ultibo I should get better control as I am hopeless at understanding the ins and outs of Linux.
I'm a hardware guy too, no software training at all.

Ultibo can call C programs from the Free Pascal code.
I am hoping with fingers and toes crossed Libcamera is callable like how the Raspistill is done?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Posts: 3953
Joined: Sat Aug 18, 2012 2:33 pm

Re: controlling the processor and core allocation

Mon Jun 21, 2021 3:47 am


the HQ camera also has external sync support, so it can take an image upon a gpio trigger, entirely bypassing the pi

Return to “Advanced users”