• Cedric Roux's avatar
    fix issue 227 - UE IP settings disrupts realtime · cff91499
    Cedric Roux authored
    see https://gitlab.eurecom.fr/oai/openairinterface5g/issues/227
    
    When the UE connects to the eNodeB and receives its IP address from the
    network, it calls system() to set it in the linux kernel world. This call
    is not done in a realtime thread, but in the NAS, which uses its own thread,
    independent of the realtime processing.
    
    In some situations this totally disrupts realtime processing.
    
    It is difficult to know precisely why that happens, but it seems that calling
    fork(), as system() does, in a multi-threaded program is not a good idea. (So
    say several people on the internet.) It is not clear why the softmodem is
    impacted, but it seems that fork() is really what triggers the disruption.
    Several tests lead to that conclusion.
    
    To fix the problem, we create a child background process very early in main()
    (before anything else basically). Then instead of calling system(), the main
    process sends the string to the background process. The background process
    gets the string, passes it to system() and reports the success/failure back
    to the main process.
    
    This solution involves a lot of system calls, but calling system() in the
    first place is not cheap either. As long as no realtime thread uses this
    mechanism, things should be fine. Time will tell.
    cff91499
system.h 1.53 KB
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
 * the OAI Public License, Version 1.0  (the "License"); you may not use this file
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */

#ifndef _SYSTEM_H_OAI_
#define _SYSTEM_H_OAI_

/****************************************************
 * send a command to the background process
 *     return -1 on error, 0 on success
 ****************************************************/

int background_system(char *command);

/****************************************************
 * initialize the background process
 *     to be called very early
 ****************************************************/

void start_background_system(void);

#endif /* _SYSTEM_H_OAI_ */