Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Supporting multiple cores from bare metal C

Supporting multiple cores from bare metal C

Scheduled Pinned Locked Moved The Weird and The Wonderful
designasp-netcomgraphicsiot
7 Posts 3 Posters 32 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    honey the codewitch
    wrote on last edited by
    #1

    I always wondered what a bare metal C implementation - the kind you'd use to write even parts of low level boot loader code would do to expose things like a 2nd core. Or rather, how do you use a 2nd core without a scheduler? I've always kinda wondered about that. The answer is simple. You activate the core in the bootloader and then get the core to JMP to your code. One main() in effect, for each core.

    extern "C" void aux_core_main()
    {
    // 2nd core just starts here. Spin a loop. Be happy.
    }

    Synchronization is a whole different story, but if you don't need to synchronize, why waste any overhead on scheduling?

    Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

    1 K 2 Replies Last reply
    0
    • H honey the codewitch

      I always wondered what a bare metal C implementation - the kind you'd use to write even parts of low level boot loader code would do to expose things like a 2nd core. Or rather, how do you use a 2nd core without a scheduler? I've always kinda wondered about that. The answer is simple. You activate the core in the bootloader and then get the core to JMP to your code. One main() in effect, for each core.

      extern "C" void aux_core_main()
      {
      // 2nd core just starts here. Spin a loop. Be happy.
      }

      Synchronization is a whole different story, but if you don't need to synchronize, why waste any overhead on scheduling?

      Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

      1 Offline
      1 Offline
      11917640 Member
      wrote on last edited by
      #2

      Symmetric Multiprocessing (SMP) with FreeRTOS

      H 1 Reply Last reply
      0
      • 1 11917640 Member

        Symmetric Multiprocessing (SMP) with FreeRTOS

        H Offline
        H Offline
        honey the codewitch
        wrote on last edited by
        #3

        That's using a scheduler and an OS. The point of my post was what happens with 2nd core activation in the absence of a scheduler.

        Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

        1 1 Reply Last reply
        0
        • H honey the codewitch

          That's using a scheduler and an OS. The point of my post was what happens with 2nd core activation in the absence of a scheduler.

          Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

          1 Offline
          1 Offline
          11917640 Member
          wrote on last edited by
          #4

          Nice. It's always interesting to go more and more "bare" in bare metal development. Regarding RTOS - I am surprised, that it is called OS, I always think about it as kind of multitasking library. Not full-featured OS like embedded Linux, and available in bare metal projects.

          H 1 Reply Last reply
          0
          • 1 11917640 Member

            Nice. It's always interesting to go more and more "bare" in bare metal development. Regarding RTOS - I am surprised, that it is called OS, I always think about it as kind of multitasking library. Not full-featured OS like embedded Linux, and available in bare metal projects.

            H Offline
            H Offline
            honey the codewitch
            wrote on last edited by
            #5

            Well for the purposes of what I'm talking about an RTOS (which is a kind of OS, albeit a RealTime OS) is an operating system. It has a scheduler to handle context switching. :)

            Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

            1 Reply Last reply
            0
            • H honey the codewitch

              I always wondered what a bare metal C implementation - the kind you'd use to write even parts of low level boot loader code would do to expose things like a 2nd core. Or rather, how do you use a 2nd core without a scheduler? I've always kinda wondered about that. The answer is simple. You activate the core in the bootloader and then get the core to JMP to your code. One main() in effect, for each core.

              extern "C" void aux_core_main()
              {
              // 2nd core just starts here. Spin a loop. Be happy.
              }

              Synchronization is a whole different story, but if you don't need to synchronize, why waste any overhead on scheduling?

              Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

              K Offline
              K Offline
              klinkenbecker
              wrote on last edited by
              #6

              This is not as complicated as you might think. It is just another processor - you set up a 'context' (stack, memory & code spaces and an entry point), initialize the core as needed and 'start' - it will run. I played with a very early open multicore processor maybe 15 years ago. After you get over the initial buzz, it is just like running tasks on any other processor (so, ho-hum). Chopping up a C program to efficiently take advantage of multiple cores, on the other hand, is something else entirely and not for the faint of heart - and something I have never thought would stop you.

              H 1 Reply Last reply
              0
              • K klinkenbecker

                This is not as complicated as you might think. It is just another processor - you set up a 'context' (stack, memory & code spaces and an entry point), initialize the core as needed and 'start' - it will run. I played with a very early open multicore processor maybe 15 years ago. After you get over the initial buzz, it is just like running tasks on any other processor (so, ho-hum). Chopping up a C program to efficiently take advantage of multiple cores, on the other hand, is something else entirely and not for the faint of heart - and something I have never thought would stop you.

                H Offline
                H Offline
                honey the codewitch
                wrote on last edited by
                #7

                I just thought it was interesting that it was effectively a second main(). I was expecting something more complicated for some reason. And yeah, synchronization is the real mess, especially when you need to build up the primitives from scratch. :)

                Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups