Home | History | Annotate | Download | only in cpuctl_fj
      1 /******************************************************************************/
      2 /*                                                                            */
      3 /* Copyright (c) 2009 FUJITSU LIMITED                                         */
      4 /*                                                                            */
      5 /* This program is free software;  you can redistribute it and/or modify      */
      6 /* it under the terms of the GNU General Public License as published by       */
      7 /* the Free Software Foundation; either version 2 of the License, or          */
      8 /* (at your option) any later version.                                        */
      9 /*                                                                            */
     10 /* This program is distributed in the hope that it will be useful,            */
     11 /* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
     12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
     13 /* the GNU General Public License for more details.                           */
     14 /*                                                                            */
     15 /* You should have received a copy of the GNU General Public License          */
     16 /* along with this program;  if not, write to the Free Software               */
     17 /* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
     18 /*                                                                            */
     19 /* Author: Miao Xie <miaox (at) cn.fujitsu.com>                                    */
     20 /* Restructure for LTP: Shi Weihua <shiwh (at) cn.fujitsu.com>                     */
     21 /*                                                                            */
     22 /******************************************************************************/
     23 
     24 #include <stdio.h>
     25 #include <math.h>
     26 #include <err.h>
     27 #include <errno.h>
     28 #include <signal.h>
     29 
     30 #define __USE_GNU
     31 #include <sched.h>
     32 
     33 #define UNUSED __attribute__ ((unused))
     34 
     35 unsigned long count;
     36 volatile int start = 0;
     37 volatile double f = 2744545.34456455;
     38 
     39 void sighandler(UNUSED int signo)
     40 {
     41 	start = !start;
     42 }
     43 
     44 int main(void)
     45 {
     46 	sigset_t sigset;
     47 	struct sigaction sa;
     48 
     49 	sa.sa_handler = sighandler;
     50 	if (sigemptyset(&sa.sa_mask) < 0)
     51 		err(1, "sigemptyset()");
     52 
     53 	sa.sa_flags = 0;
     54 	if (sigaction(SIGUSR1, &sa, NULL) < 0)
     55 		err(1, "sigaction()");
     56 
     57 	if (sigemptyset(&sigset) < 0)
     58 		err(1, "sigemptyset()");
     59 
     60 	sigsuspend(&sigset);
     61 	if (errno != EINTR)
     62 		err(1, "sigsuspend()");
     63 
     64 	while (start) {
     65 		f = sqrt(f * f);
     66 	}
     67 
     68 	return 0;
     69 }
     70