#include <pthread.h>
#include <stdio.h>

/* keep precessor bysy */
void *load_thread(void *arg)
{
    int i;
    float f, g;

    for(;;)
    {
        f = 1.0; 
        for (i = 0; i < 1000; i++) { f *= 2.0; g = f; g /= 2.0; f = g;}

	sleep(1);
    }
}
/* do tics */
void *tic_thread(void *arg)
{
    int i;

    for(i = 0;; i++)
    {
        /* first tic thread will print */
        if (!arg && (i == 10)) { printf("1 second\n"); i = 0; }
	usleep(100000); /*100ms*/
    }
}

main()
{
    struct timeval tp;
    pthread_t thread;
    int i;

    pthread_init();

    for (i = 0; i < 10; i++) pthread_create(&thread, NULL, load_thread, NULL);
gettimeofday(&tp, NULL);
pthread_create(&thread, NULL, tic_thread, (void *)0);
printf("thread id = %x time = %d %d\n", (void *) thread, tp.tv_sec, tp.tv_usec);
    for (i = 1; i < 10; i++) pthread_create(&thread, NULL, tic_thread, (void *) i);

    for(;;) sleep(10000);
}
