]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
Added packet budgeting into vres_tx_thread
authorMartin Molnar <molnar@sum.(none)>
Wed, 20 Feb 2008 17:49:59 +0000 (18:49 +0100)
committerMartin Molnar <molnar@sum.(none)>
Wed, 20 Feb 2008 17:49:59 +0000 (18:49 +0100)
fwp/lib/fwp_ac.c
fwp/lib/fwp_vres.c
fwp/tests/fwp_vrestest/fwp_vrestest.c

index 2299ca428c8e10982e64682832edf5d162b1631a..5e60d376bcd1a1c08ebb44f7edf6a2e8c0ff8490 100644 (file)
@@ -94,15 +94,5 @@ int fwp_ac_send(unsigned int id, struct fwp_msgb* msgb)
                return -EINVAL;*/
        _fwp_sendto(fwp_ac_table[id].sockfd, msgb->data, msgb->len, 0, 
                        msgb->peer->addr, msgb->peer->addrlen);
-#if 0
-       while (sendto(fwp_ac_table[id].sockfd, msgb->data, msgb->len,
-                     /*msgb_>flags*/0, (struct sockaddr*)msgb->peer->addr, 
-                     msgb->peer->addrlen) < 0) {
-
-               if (errno == EINTR) continue;
-               perror("fwp_ac_send - Error while sending data");
-               return (-errno);
-       }
-#endif 
        return 0;
 }
index 124c430d80928ae13808ec46f7256aad0b94de41..f6aee03d53351037e04dc9aeaff1e5ac58290338 100644 (file)
@@ -142,20 +142,20 @@ static void fwp_vres_cleanup(void *_vres)
 }
 
 static void* fwp_vres_tx_thread(void *_vres)
-{/* TODO: Implement budgeting, make changes that count with changing of params */
+{/* TODO: make changes that count with changing of params */
        struct fwp_vres *vres = (struct fwp_vres*)_vres;
        struct fwp_msgq *msgq = &vres->tx_queue;
        struct fwp_msgb *msgb;
-       unsigned int ac_id = vres->params.ac_id;
-       int rc;
+       unsigned int    ac_id = vres->params.ac_id;
+       int             budget = vres->params.budget;
+       int             curr_budget;
+       int             rc;
                
        struct timespec  start_period, end_period, period;
        struct timespec  current_time, interval;
 
        period.tv_nsec = vres->params.period_usec % SEC_TO_USEC;
        period.tv_sec = vres->params.period_usec / SEC_TO_USEC;
-       FWP_DEBUG("Iterval: sec = %ld nsec = %ld \n", period.tv_sec,
-                               period.tv_nsec);
        
        fwp_set_rt_prio(90 - ac_id);
        
@@ -170,12 +170,15 @@ static void* fwp_vres_tx_thread(void *_vres)
                sem_wait(&msgq->empty_lock);
                clock_gettime(CLOCK_MONOTONIC, &start_period);
                
-               msgb = fwp_msgq_dequeue(msgq);
-               
-               if (msgb) {
-                       /* TODO: rc handling */
+               curr_budget = 0;
+               while ((msgb = fwp_msgq_dequeue(msgq)) &&
+                      (curr_budget < budget)) {
+                       
                        rc = fwp_ac_send(ac_id, msgb);
-                       FWP_DEBUG("Message sent through AC %d\n",ac_id);
+                       if (!(rc < 0)) {
+                               FWP_DEBUG("Message sent through AC%d\n",ac_id);
+                               curr_budget+= msgb->len;
+                       }
                        fwp_msgb_free(msgb);
                }
 
@@ -184,12 +187,8 @@ static void* fwp_vres_tx_thread(void *_vres)
                
                fwp_timespec_add(&end_period, &start_period, &period);
                clock_gettime(CLOCK_MONOTONIC, &current_time);
-               FWP_DEBUG("sec = %ld nsec = %ld \n", current_time.tv_sec,
-                               current_time.tv_nsec);
                fwp_timespec_sub(&interval, &end_period, &current_time);
                nanosleep(&interval, NULL);
-               FWP_DEBUG("Iterval: sec = %ld nsec = %ld \n", interval.tv_sec,
-                               interval.tv_nsec);
        }
        
        /* it should normaly never come here */ 
index 99c76085b26d316ad2526fbdf4fcdd0527df4c4d..c3b36a1213a4aa303374458fc93ff006dc5e8783 100644 (file)
@@ -18,6 +18,7 @@ int main()
        char buffer[30];
        int sepoint_id1, repoint_id;
        int count;
+       struct timespec  sendtime;
 
        vparam1.ac_id = FWP_AC_VO; 
        vparam1.budget = 100;
@@ -48,6 +49,11 @@ int main()
        
        for (count = 0; count < NUM; count++) { 
                fwp_send(sepoint_id1, msg1, sizeof(msg1));
+               
+               clock_gettime(CLOCK_MONOTONIC, &sendtime);
+               FWP_DEBUG("Sent: sec = %ld nsec = %ld \n", sendtime.tv_sec,
+                               sendtime.tv_nsec);
+               
                printf("count= %d\n", count++);
                if ((len = fwp_recv(repoint_id, buffer, sizeof(buffer))) < 0) {
                        perror("Error while receiving data");