Commit 129d4833 authored by laurent's avatar laurent

more fixes in mutext

parent 5e47fa4d
/* /*
Author: Laurent THOMAS, Open Cells for Nokia Author: Laurent THOMAS, Open Cells for Nokia
copyleft: OpenAirInterface Software Alliance and it's licence copyleft: OpenAirInterface Software Alliance and it's licence
...@@ -326,7 +325,6 @@ bool flushInput(rfsimulator_state_t *t) { ...@@ -326,7 +325,6 @@ bool flushInput(rfsimulator_state_t *t) {
return nfds>0; return nfds>0;
} }
int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, void **samplesVoid, int nsamps, int nbAnt) { int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, void **samplesVoid, int nsamps, int nbAnt) {
if (nbAnt != 1) { LOG_E(HW, "rfsimulator: only 1 antenna tested\n"); exit(1); } if (nbAnt != 1) { LOG_E(HW, "rfsimulator: only 1 antenna tested\n"); exit(1); }
...@@ -413,6 +411,7 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo ...@@ -413,6 +411,7 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
return nsamps; return nsamps;
} }
int rfsimulator_request(openair0_device *device, void *msg, ssize_t msg_len) { int rfsimulator_request(openair0_device *device, void *msg, ssize_t msg_len) {
abort(); abort();
return 0; return 0;
...@@ -442,6 +441,7 @@ int rfsimulator_set_gains(openair0_device *device, openair0_config_t *openair0_c ...@@ -442,6 +441,7 @@ int rfsimulator_set_gains(openair0_device *device, openair0_config_t *openair0_c
__attribute__((__visibility__("default"))) __attribute__((__visibility__("default")))
int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
//set_log(HW,OAILOG_DEBUG); //set_log(HW,OAILOG_DEBUG);
//set_log(PHY,OAILOG_DEBUG);
rfsimulator_state_t *rfsimulator = (rfsimulator_state_t *)calloc(sizeof(rfsimulator_state_t),1); rfsimulator_state_t *rfsimulator = (rfsimulator_state_t *)calloc(sizeof(rfsimulator_state_t),1);
if ((rfsimulator->ip=getenv("RFSIMULATOR")) == NULL ) { if ((rfsimulator->ip=getenv("RFSIMULATOR")) == NULL ) {
......
...@@ -544,7 +544,7 @@ static void *UE_thread_synch(void *arg) ...@@ -544,7 +544,7 @@ static void *UE_thread_synch(void *arg)
while (UE->proc.instance_cnt_synch < 0) while (UE->proc.instance_cnt_synch < 0)
// the thread waits here most of the time // the thread waits here most of the time
pthread_cond_wait( &UE->proc.cond_synch, &UE->proc.mutex_synch ); pthread_cond_wait( &UE->proc.cond_synch, &UE->proc.mutex_synch );
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
LOG_I(PHY,"Starting a sync process\n"); LOG_I(PHY,"Starting a sync process\n");
switch (sync_mode) { switch (sync_mode) {
case pss: case pss:
...@@ -647,9 +647,7 @@ static void *UE_thread_synch(void *arg) ...@@ -647,9 +647,7 @@ static void *UE_thread_synch(void *arg)
UE->UE_scan_carrier = 0; UE->UE_scan_carrier = 0;
} else { } else {
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
UE->is_synchronized = 1; UE->is_synchronized = 1;
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
if( UE->mode == rx_dump_frame ) { if( UE->mode == rx_dump_frame ) {
FILE *fd; FILE *fd;
...@@ -667,10 +665,7 @@ static void *UE_thread_synch(void *arg) ...@@ -667,10 +665,7 @@ static void *UE_thread_synch(void *arg)
exit(0); exit(0);
} }
} else { } else {
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
UE->is_synchronized = 0; UE->is_synchronized = 0;
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
} }
} }
} }
...@@ -719,7 +714,6 @@ static void *UE_thread_synch(void *arg) ...@@ -719,7 +714,6 @@ static void *UE_thread_synch(void *arg)
break; break;
} }
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
// indicate readiness // indicate readiness
UE->proc.instance_cnt_synch--; UE->proc.instance_cnt_synch--;
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
...@@ -773,18 +767,10 @@ static void *UE_thread_rxn_txnp4(void *arg) { ...@@ -773,18 +767,10 @@ static void *UE_thread_rxn_txnp4(void *arg) {
threadname); threadname);
while (!oai_exit) { while (!oai_exit) {
if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) { AssertFatal(pthread_mutex_lock(&proc->mutex_rxtx) == 0, "[SCHED][UE] error locking mutex for UE RXTX\n" );
LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" ); while (proc->instance_cnt_rxtx < 0)
exit_fun("nothing to add");
}
while (proc->instance_cnt_rxtx < 0) {
// most of the time, the thread is waiting here // most of the time, the thread is waiting here
pthread_cond_wait( &proc->cond_rxtx, &proc->mutex_rxtx ); pthread_cond_wait( &proc->cond_rxtx, &proc->mutex_rxtx );
}
if (pthread_mutex_unlock(&proc->mutex_rxtx) != 0) {
LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXn_TXnp4\n" );
exit_fun("nothing to add");
}
initRefTimes(t2); initRefTimes(t2);
initRefTimes(t3); initRefTimes(t3);
...@@ -858,18 +844,8 @@ static void *UE_thread_rxn_txnp4(void *arg) { ...@@ -858,18 +844,8 @@ static void *UE_thread_rxn_txnp4(void *arg) {
phy_procedures_UE_S_TX(UE,0,0); phy_procedures_UE_S_TX(UE,0,0);
updateTimes(current, &t3, 10000, "Delay to process sub-frame (case 3)"); updateTimes(current, &t3, 10000, "Delay to process sub-frame (case 3)");
if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) {
LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" );
exit_fun("noting to add");
}
proc->instance_cnt_rxtx--; proc->instance_cnt_rxtx--;
#if BASIC_SIMULATOR AssertFatal (pthread_mutex_unlock(&proc->mutex_rxtx) == 0, "[SCHED][UE] error unlocking mutex for UE RXTX\n" );
if (pthread_cond_signal(&proc->cond_rxtx) != 0) abort();
#endif
if (pthread_mutex_unlock(&proc->mutex_rxtx) != 0) {
LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXTX\n" );
exit_fun("noting to add");
}
} }
// thread finished // thread finished
...@@ -1557,21 +1533,45 @@ void *UE_thread(void *arg) { ...@@ -1557,21 +1533,45 @@ void *UE_thread(void *arg) {
oai_exit=1; oai_exit=1;
} }
UE_rxtx_proc_t *proc=UE->proc.proc_rxtx;
while (!oai_exit) { while (!oai_exit) {
#if BASIC_SIMULATOR
while (!(UE->proc.instance_cnt_synch < 0)) { if ( pthread_mutex_trylock(&UE->proc.mutex_synch) != 0 ) {
printf("ue sync not ready\n"); // a sync detection is running
usleep(500*1000); // grab 10 ms of signal into dummy buffer to wait result of sync detection
if (UE->mode != loop_through_memory) {
void *dummy_tx[UE->frame_parms.nb_antennas_tx];
for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
dummy_tx[i]=malloc16_clear(UE->frame_parms.samples_per_tti*4);
void *dummy_rx[UE->frame_parms.nb_antennas_rx];
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
dummy_rx[i]=malloc16(UE->frame_parms.samples_per_tti*4);
for (int sf=0; sf<10; sf++) {
// printf("Reading dummy sf %d\n",sf);
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
dummy_rx,
UE->frame_parms.samples_per_tti,
UE->frame_parms.nb_antennas_rx);
AssertFatal( UE->frame_parms.samples_per_tti ==
UE->rfdevice.trx_write_func(&UE->rfdevice,
timestamp+(2*UE->frame_parms.samples_per_tti) -
openair0_cfg[0].tx_sample_advance,
dummy_tx,
UE->frame_parms.samples_per_tti,
UE->frame_parms.nb_antennas_tx,
1),"");
}
for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
free(dummy_tx[i]);
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
free(dummy_rx[i]);
}
usleep(1000); // relax time when I/Q acquisition is not realtime (simulators)
continue;
} }
#endif
AssertFatal ( 0 == pthread_mutex_lock(&UE->proc.mutex_synch), "");
int instance_cnt_synch = UE->proc.instance_cnt_synch;
int is_synchronized = UE->is_synchronized;
AssertFatal ( 0 == pthread_mutex_unlock(&UE->proc.mutex_synch), "");
if (is_synchronized == 0) { if (UE->is_synchronized == 0) {
if (instance_cnt_synch < 0) { // we can invoke the synch
// grab 10 ms of signal and wakeup synch thread // grab 10 ms of signal and wakeup synch thread
if (UE->mode != loop_through_memory) { if (UE->mode != loop_through_memory) {
void *dummy_tx[UE->frame_parms.nb_antennas_tx]; void *dummy_tx[UE->frame_parms.nb_antennas_tx];
...@@ -1598,245 +1598,203 @@ void *UE_thread(void *arg) { ...@@ -1598,245 +1598,203 @@ void *UE_thread(void *arg) {
for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++) for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
free(dummy_tx[i]); free(dummy_tx[i]);
} }
AssertFatal( 0 == pthread_mutex_lock(&UE->proc.mutex_synch), ""); UE->proc.instance_cnt_synch=0;
AssertFatal( 0 == ++UE->proc.instance_cnt_synch, "[SCHED][UE] UE sync thread busy!!\n" );
AssertFatal( 0 == pthread_cond_signal(&UE->proc.cond_synch), ""); AssertFatal( 0 == pthread_cond_signal(&UE->proc.cond_synch), "");
AssertFatal( 0 == pthread_mutex_unlock(&UE->proc.mutex_synch), ""); AssertFatal( 0 == pthread_mutex_unlock(&UE->proc.mutex_synch), "");
} else { continue;
// grab 10 ms of signal into dummy buffer to wait result of sync detection } // UE->is_synchronized==0
if (UE->mode != loop_through_memory) {
// UE is synchronized
AssertFatal( 0 == pthread_mutex_unlock(&UE->proc.mutex_synch), "");
// A specific processing for first sub-frame after synchro
if (start_rx_stream==0) {
start_rx_stream=1;
if (UE->mode != loop_through_memory) {
if (UE->no_timing_correction==0) {
LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode);
void *dummy_tx[UE->frame_parms.nb_antennas_tx]; void *dummy_tx[UE->frame_parms.nb_antennas_tx];
for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++) for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
dummy_tx[i]=malloc16_clear(UE->frame_parms.samples_per_tti*4); dummy_tx[i]=malloc16_clear(UE->frame_parms.samples_per_tti*4);
void *dummy_rx[UE->frame_parms.nb_antennas_rx]; for ( int size=UE->rx_offset ; size > 0 ; size -= UE->frame_parms.samples_per_tti ) {
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++) int unitTransfer=size>UE->frame_parms.samples_per_tti ? UE->frame_parms.samples_per_tti : size ;
dummy_rx[i]=malloc16(UE->frame_parms.samples_per_tti*4); AssertFatal(unitTransfer ==
for (int sf=0; sf<10; sf++) { UE->rfdevice.trx_read_func(&UE->rfdevice,
// printf("Reading dummy sf %d\n",sf); &timestamp,
UE->rfdevice.trx_read_func(&UE->rfdevice, (void**)UE->common_vars.rxdata,
&timestamp, unitTransfer,
dummy_rx, UE->frame_parms.nb_antennas_rx),"");
UE->frame_parms.samples_per_tti, AssertFatal( unitTransfer ==
UE->frame_parms.nb_antennas_rx); UE->rfdevice.trx_write_func(&UE->rfdevice,
AssertFatal( UE->frame_parms.samples_per_tti == timestamp+(2*UE->frame_parms.samples_per_tti) -
UE->rfdevice.trx_write_func(&UE->rfdevice, openair0_cfg[0].tx_sample_advance,
timestamp+(2*UE->frame_parms.samples_per_tti) - dummy_tx,
openair0_cfg[0].tx_sample_advance, unitTransfer,
dummy_tx, UE->frame_parms.nb_antennas_tx,
UE->frame_parms.samples_per_tti, 1),"");
UE->frame_parms.nb_antennas_tx,
1),"");
usleep(900); // this sleep improves in the case of simulated RF and doesn't harm with true radio
} }
for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++) for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
free(dummy_tx[i]); free(dummy_tx[i]);
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
free(dummy_rx[i]);
} }
} UE->rx_offset=0;
UE->time_sync_cell=0;
} // UE->is_synchronized==0 //UE->proc.proc_rxtx[0].frame_rx++;
else { //UE->proc.proc_rxtx[1].frame_rx++;
if (start_rx_stream==0) { for (th_id=0; th_id < RX_NB_TH; th_id++) {
start_rx_stream=1; UE->proc.proc_rxtx[th_id].frame_rx++;
if (UE->mode != loop_through_memory) { }
if (UE->no_timing_correction==0) {
LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode); // read in first symbol
void *dummy_tx[UE->frame_parms.nb_antennas_tx]; AssertFatal (UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0 ==
for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++) UE->rfdevice.trx_read_func(&UE->rfdevice,
dummy_tx[i]=malloc16_clear(UE->frame_parms.samples_per_tti*4); &timestamp,
for ( int size=UE->rx_offset ; size > 0 ; size -= UE->frame_parms.samples_per_tti ) { (void**)UE->common_vars.rxdata,
int unitTransfer=size>UE->frame_parms.samples_per_tti ? UE->frame_parms.samples_per_tti : size ; UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0,
AssertFatal(unitTransfer == UE->frame_parms.nb_antennas_rx),"");
UE->rfdevice.trx_read_func(&UE->rfdevice, slot_fep(UE,0, 0, 0, 0, 0);
&timestamp, } //UE->mode != loop_through_memory
(void**)UE->common_vars.rxdata, else
unitTransfer, rt_sleep_ns(1000*1000);
UE->frame_parms.nb_antennas_rx),""); continue;
AssertFatal( unitTransfer == }
UE->rfdevice.trx_write_func(&UE->rfdevice,
timestamp+(2*UE->frame_parms.samples_per_tti) - // Normale subframe processing
openair0_cfg[0].tx_sample_advance, sub_frame= (sub_frame + 1 ) % 10;
dummy_tx, //Force wait in simulation because odd and even subframe processing threads seems to haverace conditions
unitTransfer, AssertFatal(proc,"");
UE->frame_parms.nb_antennas_tx, if ( getenv("RFSIMULATOR")) {
1),""); bool ok;
} do {
for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++) pthread_mutex_lock(&proc->mutex_rxtx);
free(dummy_tx[i]); ok=proc->instance_cnt_rxtx==-1;
} pthread_mutex_unlock(&proc->mutex_rxtx);
UE->rx_offset=0; } while (!ok);
UE->time_sync_cell=0; }
//UE->proc.proc_rxtx[0].frame_rx++;
//UE->proc.proc_rxtx[1].frame_rx++;
for (th_id=0; th_id < RX_NB_TH; th_id++) {
UE->proc.proc_rxtx[th_id].frame_rx++;
}
// read in first symbol
AssertFatal (UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0 ==
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
(void**)UE->common_vars.rxdata,
UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0,
UE->frame_parms.nb_antennas_rx),"");
slot_fep(UE,0, 0, 0, 0, 0);
} //UE->mode != loop_through_memory
else
rt_sleep_ns(1000*1000);
} else {
sub_frame++;
sub_frame%=10;
UE_rxtx_proc_t *proc = &UE->proc.proc_rxtx[thread_idx];
// update thread index for received subframe
UE->current_thread_id[sub_frame] = thread_idx;
#if BASIC_SIMULATOR #if BASIC_SIMULATOR
{ pthread_mutex_lock(&proc->mutex_rxtx);
int t; pthread_mutex_unlock(&proc->mutex_rxtx);
for (t = 0; t < 2; t++) {
UE_rxtx_proc_t *proc = &UE->proc.proc_rxtx[t];
pthread_mutex_lock(&proc->mutex_rxtx);
while (proc->instance_cnt_rxtx >= 0) pthread_cond_wait( &proc->cond_rxtx, &proc->mutex_rxtx );
pthread_mutex_unlock(&proc->mutex_rxtx);
}
}
#endif #endif
LOG_D(PHY,"Process Subframe %d thread Idx %d \n", sub_frame, UE->current_thread_id[sub_frame]); LOG_D(PHY,"Process Subframe %d thread Idx %d \n", sub_frame, UE->current_thread_id[sub_frame]);
proc = &UE->proc.proc_rxtx[thread_idx];
thread_idx++; // update thread index for received subframe
if(thread_idx>=RX_NB_TH) UE->current_thread_id[sub_frame] = thread_idx;
thread_idx = 0;
LOG_D(PHY,"Process Subframe %d thread Idx %d \n", sub_frame, UE->current_thread_id[sub_frame]);
if (UE->mode != loop_through_memory) { thread_idx= (thread_idx + 1 ) % RX_NB_TH;
for (i=0; i<UE->frame_parms.nb_antennas_rx; i++) if (UE->mode != loop_through_memory) {
rxp[i] = (void*)&UE->common_vars.rxdata[i][UE->frame_parms.ofdm_symbol_size+ for (i=0; i<UE->frame_parms.nb_antennas_rx; i++)
UE->frame_parms.nb_prefix_samples0+ rxp[i] = (void*)&UE->common_vars.rxdata[i][UE->frame_parms.ofdm_symbol_size+
sub_frame*UE->frame_parms.samples_per_tti]; UE->frame_parms.nb_prefix_samples0+
for (i=0; i<UE->frame_parms.nb_antennas_tx; i++) sub_frame*UE->frame_parms.samples_per_tti];
txp[i] = (void*)&UE->common_vars.txdata[i][((sub_frame+2)%10)*UE->frame_parms.samples_per_tti]; for (i=0; i<UE->frame_parms.nb_antennas_tx; i++)
txp[i] = (void*)&UE->common_vars.txdata[i][((sub_frame+2)%10)*UE->frame_parms.samples_per_tti];
int readBlockSize, writeBlockSize;
if (sub_frame<9) { int readBlockSize, writeBlockSize;
readBlockSize=UE->frame_parms.samples_per_tti; if (sub_frame<9) {
writeBlockSize=UE->frame_parms.samples_per_tti; readBlockSize=UE->frame_parms.samples_per_tti;
} else { writeBlockSize=UE->frame_parms.samples_per_tti;
// set TO compensation to zero } else {
// set TO compensation to zero
UE->rx_offset_diff = 0;
UE->rx_offset_diff = 0;
// compute TO compensation that should be applied for this frame
// compute TO compensation that should be applied for this frame
if (UE->no_timing_correction == 0) {
if (getenv("RFSIMULATOR") != NULL && UE->rx_offset) { if (UE->no_timing_correction == 0) {
LOG_W(HW,"in simu, rx_offset is not null: %d\n", UE->rx_offset); if ( UE->rx_offset < 5*UE->frame_parms.samples_per_tti &&
} UE->rx_offset > 0 )
if ( UE->rx_offset < 5*UE->frame_parms.samples_per_tti && UE->rx_offset_diff = -1 ;
UE->rx_offset > 0 ) if ( UE->rx_offset > 5*UE->frame_parms.samples_per_tti &&
UE->rx_offset_diff = -1 ; UE->rx_offset < 10*UE->frame_parms.samples_per_tti )
if ( UE->rx_offset > 5*UE->frame_parms.samples_per_tti && UE->rx_offset_diff = 1;
UE->rx_offset < 10*UE->frame_parms.samples_per_tti ) }
UE->rx_offset_diff = 1;
} LOG_D(PHY,"AbsSubframe %d.%d SET rx_off_diff to %d rx_offset %d \n",
proc->frame_rx,sub_frame,UE->rx_offset_diff,UE->rx_offset);
LOG_D(PHY,"AbsSubframe %d.%d SET rx_off_diff to %d rx_offset %d \n",proc->frame_rx,sub_frame,UE->rx_offset_diff,UE->rx_offset); if (getenv("RFSIMULATOR") != NULL && UE->rx_offset) {
readBlockSize=UE->frame_parms.samples_per_tti - LOG_W(HW,"in simu, rx_offset is not null: %d\n", UE->rx_offset);
UE->frame_parms.ofdm_symbol_size - //UE->rx_offset_diff=0;
UE->frame_parms.nb_prefix_samples0 - }
UE->rx_offset_diff; readBlockSize=UE->frame_parms.samples_per_tti -
writeBlockSize=UE->frame_parms.samples_per_tti - UE->frame_parms.ofdm_symbol_size -
UE->rx_offset_diff; UE->frame_parms.nb_prefix_samples0 -
} UE->rx_offset_diff;
writeBlockSize=UE->frame_parms.samples_per_tti -
AssertFatal(readBlockSize == UE->rx_offset_diff;
UE->rfdevice.trx_read_func(&UE->rfdevice, }
&timestamp,
rxp, AssertFatal(readBlockSize ==
readBlockSize, UE->rfdevice.trx_read_func(&UE->rfdevice,
UE->frame_parms.nb_antennas_rx),""); &timestamp,
AssertFatal( writeBlockSize == rxp,
UE->rfdevice.trx_write_func(&UE->rfdevice, readBlockSize,
timestamp+ UE->frame_parms.nb_antennas_rx),"");
(2*UE->frame_parms.samples_per_tti) - AssertFatal( writeBlockSize ==
UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 - UE->rfdevice.trx_write_func(&UE->rfdevice,
openair0_cfg[0].tx_sample_advance, timestamp+
txp, (2*UE->frame_parms.samples_per_tti) -
writeBlockSize, UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 -
UE->frame_parms.nb_antennas_tx, openair0_cfg[0].tx_sample_advance,
1),""); txp,
if( sub_frame==9) { writeBlockSize,
// read in first symbol of next frame and adjust for timing drift UE->frame_parms.nb_antennas_tx,
int first_symbols=writeBlockSize-readBlockSize; 1),"");
if ( first_symbols > 0 ) { if( sub_frame==9) {
openair0_timestamp timestamp1; // read in first symbol of next frame and adjust for timing drift
AssertFatal(first_symbols == int first_symbols=writeBlockSize-readBlockSize;
UE->rfdevice.trx_read_func(&UE->rfdevice, if ( first_symbols > 0 ) {
&timestamp1, openair0_timestamp timestamp1;
(void**)UE->common_vars.rxdata, AssertFatal(first_symbols ==
first_symbols, UE->rfdevice.trx_read_func(&UE->rfdevice,
UE->frame_parms.nb_antennas_rx),""); &timestamp1,
} (void**)UE->common_vars.rxdata,
if ( first_symbols <0 ) first_symbols,
LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols); UE->frame_parms.nb_antennas_rx),"");
} }
pickTime(gotIQs); if ( first_symbols <0 )
// operate on thread sf mod 2 LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols);
AssertFatal(pthread_mutex_lock(&proc->mutex_rxtx) ==0,""); }
if(sub_frame == 0) { pickTime(gotIQs);
//UE->proc.proc_rxtx[0].frame_rx++; // operate on thread sf mod 2
//UE->proc.proc_rxtx[1].frame_rx++; if (pthread_mutex_trylock(&proc->mutex_rxtx) != 0 ) {
for (th_id=0; th_id < RX_NB_TH; th_id++) { LOG_E(PHY,"Real time issue in subframes processing, skipping subframe %d\n", proc->subframe_rx);
UE->proc.proc_rxtx[th_id].frame_rx++; continue;
} }
}
//UE->proc.proc_rxtx[0].gotIQs=readTime(gotIQs); if(sub_frame == 0) {
//UE->proc.proc_rxtx[1].gotIQs=readTime(gotIQs); //UE->proc.proc_rxtx[0].frame_rx++;
for (th_id=0; th_id < RX_NB_TH; th_id++) { //UE->proc.proc_rxtx[1].frame_rx++;
UE->proc.proc_rxtx[th_id].gotIQs=readTime(gotIQs); for (th_id=0; th_id < RX_NB_TH; th_id++) {
} UE->proc.proc_rxtx[th_id].frame_rx++;
proc->subframe_rx=sub_frame; }
proc->subframe_tx=(sub_frame+4)%10; }
proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0); //UE->proc.proc_rxtx[0].gotIQs=readTime(gotIQs);
proc->timestamp_tx = timestamp+ //UE->proc.proc_rxtx[1].gotIQs=readTime(gotIQs);
(4*UE->frame_parms.samples_per_tti)- for (th_id=0; th_id < RX_NB_TH; th_id++) {
UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0; UE->proc.proc_rxtx[th_id].gotIQs=readTime(gotIQs);
}
proc->instance_cnt_rxtx++; proc->subframe_rx=sub_frame;
LOG_D( PHY, "[SCHED][UE %d] UE RX instance_cnt_rxtx %d subframe %d !!\n", UE->Mod_id, proc->instance_cnt_rxtx,proc->subframe_rx); proc->subframe_tx=(sub_frame+4)%10;
if (proc->instance_cnt_rxtx != 0) { proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0);
proc->timestamp_tx = timestamp+
if ( getenv("RFSIMULATOR") != NULL ) { (4*UE->frame_parms.samples_per_tti)-
do { UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0;
AssertFatal (pthread_mutex_unlock(&proc->mutex_rxtx) == 0, "");
usleep(100); proc->instance_cnt_rxtx=0;
AssertFatal (pthread_mutex_lock(&proc->mutex_rxtx) == 0, ""); AssertFatal (pthread_cond_signal(&proc->cond_rxtx) ==0 ,"");
} while ( proc->instance_cnt_rxtx >= 0); AssertFatal(pthread_mutex_unlock(&proc->mutex_rxtx) ==0,"");
initRefTimes(t1);
} else initStaticTime(lastTime);
LOG_E( PHY, "[SCHED][UE %d] UE RX thread busy (IC %d)!!\n", UE->Mod_id, proc->instance_cnt_rxtx); updateTimes(lastTime, &t1, 20000, "Delay between two IQ acquisitions (case 1)");
if (proc->instance_cnt_rxtx > 2) pickStaticTime(lastTime);
exit_fun("instance_cnt_rxtx > 2");
} } else {
printf("Processing subframe %d",proc->subframe_rx);
AssertFatal (pthread_cond_signal(&proc->cond_rxtx) ==0 ,""); getchar();
AssertFatal(pthread_mutex_unlock(&proc->mutex_rxtx) ==0,""); }
initRefTimes(t1); }
initStaticTime(lastTime); return NULL;
updateTimes(lastTime, &t1, 20000, "Delay between two IQ acquisitions (case 1)");
pickStaticTime(lastTime);
} else {
printf("Processing subframe %d",proc->subframe_rx);
getchar();
}
} // start_rx_stream==1
} // UE->is_synchronized==1
} // while !oai_exit
return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment