GSW 2022 Shared Memory Layout Updates

This is not accurate anymore and needs to be changed.


This change is new as of summer/fall 2021, older GSW code only supports one telemetry packet per vehicle and only has one main block and one info block of shared memory. This is limiting in that we may have sensors that update at very different rates and don't want to send redundant data for the sensors that don't update as fast.


A primary function of the ground software is to allow telemetry from the rocket to be accessed by other processes. The data contained in telemetry packets received by the ground station are placed into shared memory, this allows the fastest access possible for multiple processes to access this data.


A vehicle can have multiple telemetry packets with data potentially overlapping between packets (e.g. one packet sends IMU data, another packet sends IMU data AND GPS data).

Each telemetry packet will get it's own telemetry block to dump raw data into and an "info" block to control locking. The locking is important to make sure processes aren't reading from the blocks at the same time another process is writing to it, it also allows reading processes to sleep until new data arrives.

The primary mechanism for locking is several layers of shared semaphores and a nonce check. A nonce is a value that is updated every write to a block, if the nonce has changed since a process last read, it has new data. The kernel allows us to block on a location in memory until it changes and the process is awoken, the nonce is guaranteed to change every write so it is also the memory location used to sleep and wake reading processes.


There will also be one "master block" of shared memory that contains a single "master nonce." This nonce is updated anytime any block is written to. The purpose of this is to establish what order telemetry blocks were written to in by comparing their nonces. Since a measurement can be in multiple telemetry packets, if you want to get the most recent value of a measurement you need to know which telemetry block was updated last.