• Cedric Roux's avatar
    bugfix: change memory management of interface between PHY and MAC scheduler · 733c7e5e
    Cedric Roux authored
    This commit fixes a bug caused by global variables in the gNB_MAC_INST
    structure used to transfer MAC scheduler's results to the PHY layer.
    
    When using several threads in the PHY layer, it may happen that the
    MAC scheduler is called a second time by the second PHY thread for the
    next slot before the content of the global variables in the gNB_MAC_INST
    structure used to store the result of the MAC scheduler for the current
    slot have been consumed by the first thread, leading to unpredictable
    results (all of them certainly wrong).
    
    The solution is to introduce a small memory management module for the
    interface between the PHY threads and the MAC scheduler. The MAC
    scheduler now fills the data structures passed to it, and not a
    global variable anymore. The PHY layer manages the structures and
    ensures that no data is overwritten before being fully consumed by
    the various threads of the PHY layer.
    
    Some care has to be taken because several PHY threads will access the
    same structures at the same time for a given slot (in read mode, so
    it's okay). A mechanism of reference counting has thus been introduced.
    
    Only one CC is supported. This restriction should not be too hard
    to remove if/when needed. (The code before this commit does not seem
    to work for more than one CC anyway.)
    733c7e5e
nr_mac_gNB.h 22.9 KB