Files
openairinterface5g/openair2/LAYER2/nr_pdcp/nr_pdcp_timer_thread.c
T
Robert Schmidt 8107939f08 Change OAI license to CSSL v1.0 (and others)
- all RAN code, CI code, configuration files, dockerfiles, in CSSL v1.0
- all deployment code (openshift, charts, ancillary files like shell
  scripts), in MIT
- documentation in CC-BY-4.0
- exceptions might apply and are listed in NOTICE
- there is a new LICENSES folder with all licenses
- CONTRIBUTIONS.md has been updated accordingly

For automated changes based on OAI PL v1.1:

    perl -i~ -0pe 's/\/\*.*Licensed to the OpenAirInterface.*openairinterface.org\n#?/\/*\n * SPDX-License-Identifier: LicenseRef-CSSL-1.0\n/s' **/*.{c,h,cpp}
    perl -i~ -0pe 's/\/\*.*Licensed to the OpenAirInterface.*openairinterface.org\n#?/\/*\n * SPDX-License-Identifier: LicenseRef-CSSL-1.0\n/s' **/*.ts
    perl -i~ -0pe 's/<!--.*Licensed to the OpenAirInterface.*openairinterface.org\n.*-->/<!-- SPDX-License-Identifier: LicenseRef-CSSL-1.0 -->/s' **/*.xml

The rest (cmake, files with missing license, cmake) manually.
2026-03-27 16:36:37 +01:00

73 lines
2.1 KiB
C

/*
* SPDX-License-Identifier: LicenseRef-CSSL-1.0
*/
#define _GNU_SOURCE
#include "nr_pdcp_timer_thread.h"
#include <stdlib.h>
#include <pthread.h>
#include <stdint.h>
#include "LOG/log.h"
static pthread_mutex_t timer_thread_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t timer_thread_cond = PTHREAD_COND_INITIALIZER;
static volatile uint64_t timer_thread_curtime = 0;
static void *nr_pdcp_timer_thread(void *_nr_pdcp_ue_manager)
{
pthread_setname_np(pthread_self(),"pdcp_timer");
nr_pdcp_ue_manager_t *nr_pdcp_ue_manager = (nr_pdcp_ue_manager_t *)_nr_pdcp_ue_manager;
nr_pdcp_ue_t **ue_list;
int ue_count;
int i;
int j;
uint64_t curtime = 0;
while (1) {
if (pthread_mutex_lock(&timer_thread_mutex) != 0) abort();
while (curtime == timer_thread_curtime)
if (pthread_cond_wait(&timer_thread_cond, &timer_thread_mutex) != 0) abort();
curtime = timer_thread_curtime;
if (pthread_mutex_unlock(&timer_thread_mutex) != 0) abort();
nr_pdcp_manager_lock(nr_pdcp_ue_manager);
ue_list = nr_pdcp_manager_get_ue_list(nr_pdcp_ue_manager);
ue_count = nr_pdcp_manager_get_ue_count(nr_pdcp_ue_manager);
for (i = 0; i < ue_count; i++) {
for (j = 0; j < 2; j++) {
if (ue_list[i]->srb[j] != NULL)
ue_list[i]->srb[j]->set_time(ue_list[i]->srb[j], curtime);
}
for (j = 0; j < 5; j++) {
if (ue_list[i]->drb[j] != NULL)
ue_list[i]->drb[j]->set_time(ue_list[i]->drb[j], curtime);
}
}
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
}
return NULL;
}
void nr_pdcp_init_timer_thread(nr_pdcp_ue_manager_t *nr_pdcp_ue_manager)
{
pthread_t t;
if (pthread_create(&t, NULL, nr_pdcp_timer_thread, nr_pdcp_ue_manager) != 0) {
LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
}
void nr_pdcp_ms_tick(void)
{
if (pthread_mutex_lock(&timer_thread_mutex)) abort();
timer_thread_curtime++;
if (pthread_cond_broadcast(&timer_thread_cond)) abort();
if (pthread_mutex_unlock(&timer_thread_mutex)) abort();
}