| 2470 | } |
| 2471 | |
| 2472 | static void *macThreadFunc(void *arg) |
| 2473 | { |
| 2474 | gL2MAC.macRunning = true; |
| 2475 | |
| 2476 | // Set the current RLC BSN. |
| 2477 | //Time tstart = gBTS.time().FN(); |
| 2478 | Time tstart = gBTS.time(); |
| 2479 | int fnstart = tstart.FN(); |
| 2480 | gBSNNext = FrameNumber2BSN(fnstart); |
| 2481 | |
| 2482 | ChIdleCounter = ChCongestionCounter = 0; |
| 2483 | |
| 2484 | // Lets start synced up on a 52-multiframe boundary. |
| 2485 | if (0) { // why bother? |
| 2486 | int offset = fnstart % 52; |
| 2487 | if (offset) { |
| 2488 | fnstart += (52 - offset); |
| 2489 | gBTS.clock().wait(fnstart); |
| 2490 | } |
| 2491 | } |
| 2492 | |
| 2493 | GPRSLOG(1) << "macServiceLoop starting:" << LOGVAR(gBSNNext) <<LOGVAR(fnstart); |
| 2494 | |
| 2495 | // We need to run the service loop even if there are no channels allocated because |
| 2496 | // the BSSG may add downlink PDUs to an MS which will create a new TBF, |
| 2497 | // which will add a channel on demand. |
| 2498 | bool firsttime = true; // First iteration. |
| 2499 | while (!gL2MAC.macStopFlag) { |
| 2500 | gL2MAC.macConfigInit(); |
| 2501 | advanceBSNNext(1); |
| 2502 | serviceLoopSynchronize(firsttime); |
| 2503 | firsttime = false; |
| 2504 | |
| 2505 | { |
| 2506 | ScopedLock lock(gL2MAC.macLock); |
| 2507 | gL2MAC.macServiceLoop(); |
| 2508 | } |
| 2509 | } |
| 2510 | |
| 2511 | GPRSLOG(1) << "macServiceLoop ending:" << LOGVAR(gBSNNext); |
| 2512 | |
| 2513 | gL2MAC.macRunning = false; |
| 2514 | return NULL; |
| 2515 | } |
| 2516 | |
| 2517 | |
| 2518 | // When the MS RACHes into the GSM RR/MM side for any reason, we must cancel ongoing TBFs. |
nothing calls this directly
no test coverage detected