Skip to contentSkip to conversation

cpuctl of controllers: fix the bug of while loop]

PATCH Subrata Modak 1 participant 1 message Sep 8, 2009 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

You have sent to the wrong mailing list. Please send a correct patch(based on LTPROOT) to the following mailing list:

ltp-list <[email protected]>,

Regards--
Subrata

Quoted 135 lines · liubo

When runing the ltp tool, I found a bug of while loop in some files of

cpuctl test.

File list:
cpuctl_def_task01.c
cpuctl_def_task02.c
cpuctl_def_task03.c
cpuctl_def_task04.c
cpuctl_test01.c
cpuctl_test02.c
cpuctl_test03.c
cpuctl_test04.c

During the compilation of these files, gcc's O2 mechanism causes the variable "timer_expired" to be omitted, hence the loop , "while(!timer_expired) f = sqrt (f*f)", cannot get right value.

Change the type of "timer_expired" from "int" to "volatile int" to fix this bug.

---

cpuctl_def_task01.c +1 -1
index 00a25bc..1fb398a 100644
@@ -82,7 +82,7 @@ extern void cleanup()
         kill(scriptpid, SIGUSR1);/* Inform the shell to do cleanup*/
         tst_exit();             /* Report exit status*/
  }
-int timer_expired = 0;
+volatile int timer_expired = 0;
 
  int main(int argc, char *argv[])
  {
cpuctl_def_task02.c +1 -1
index 1bfa187..56ddacc 100644
@@ -79,7 +79,7 @@ cleanup()
         tst_exit();             /* Report exit status*/
  }
 
-int timer_expired = 0;
+volatile int timer_expired = 0;
 
  int main(int argc, char *argv[])
  {
cpuctl_def_task03.c +1 -1
index e4ce3ad..4f3ddc1 100644
@@ -79,7 +79,7 @@ cleanup()
         tst_exit();               /* Report exit status*/
  }
 
-int timer_expired = 0;
+volatile int timer_expired = 0;
 
  int main(int argc, char *argv[])
  {
cpuctl_def_task04.c +1 -1
index 15e2b5f..7f184c8 100644
@@ -78,7 +78,7 @@ cleanup()
         tst_exit();               /* Report exit status*/
  }
 
-int timer_expired = 0;
+volatile int timer_expired = 0;
 
  int main(int argc, char *argv[])
  {
cpuctl_test01.c +1 -1
index ab0a4c9..7d7cc48 100644
@@ -80,7 +80,7 @@ cleanup()
         kill (scriptpid, SIGUSR1);/* Inform the shell to do cleanup*/
         tst_exit ();            /* Report exit status*/
  }
-int timer_expired = 0;
+volatile int timer_expired = 0;
 
  int main(int argc, char* argv[])
  {
cpuctl_test02.c +1 -1
index 801716d..153a293 100644
@@ -80,7 +80,7 @@ cleanup()
  }
 
  int migrate_task ();
-int timer_expired = 0;
+volatile int timer_expired = 0;
 
  int main(int argc, char* argv[])
  {
cpuctl_test03.c +1 -1
index c4b9978..c21b69c 100644
@@ -79,7 +79,7 @@ cleanup()
         tst_exit ();              /* Report exit status*/
  }
 
-int timer_expired = 0;
+volatile int timer_expired = 0;
 
  int main(int argc, char* argv[])
  {
cpuctl_test04.c +1 -2
index b0a2329..ed00b0d 100644
@@ -79,7 +79,7 @@ cleanup()
         tst_exit ();              /* Report exit status*/
  }
 
-int timer_expired = 0;
+volatile int timer_expired = 0;
 
  int main(int argc, char* argv[])
  {
 
 
 
------------------------------------------------------------------------------
Quoted 8 lines

Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-cvs

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list