[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

regarding thread execution



Hi All,
If this is not the place to ask this question, please point me to the appropriate list.
I use the following to set up two threads and I can't seem to determing why the last thread only runs if a system event occurs, like an exit call. Otherwise it will not run. If I add another threadm then it will run. 
Does anyone have any idea what's happening? 
Any suggestions?
The threads are loops that will exit on some condition.


            if(sched_getparam(getpid(), &sched_param) < 0)
            {
                printf("Shed getparam failed\n");
                close_ap();
            }
            if((sched_param.sched_priority = (sched_get_priority_max(SCHED_RR))) < 0)
            {
                printf("Get priority max failed\n");
                close_ap();
            }
            if(sched_setscheduler(getpid(), SCHED_RR, &sched_param))
            {
                printf("Scheduler FAILED to set Round Robin priority %i\n",
                sched_param.sched_priority);
                close_ap();
            }
            /* Modify and Start Thread execution */
            if(pthread_attr_init(&my_t_attr) != 0)
            {
                printf("FAIL to init thread attr\n");
                close_ap();
            }
            if((sched_param.sched_priority = sched_get_priority_max(SCHED_RR)) < 0)
            {
                printf("Get priority max failed\n");
                close_ap();
            }
            if(!pthread_attr_setschedparam(&my_t_attr, &sched_param))
            {
                printf("FAIL to set sched param\n");
                close_ap();
            }

            if(pthread_create(&extd_thd, &my_t_attr, extd_comm,  NULL) != 0)
            {
                printf("FAIL to create thread\n");
                close_ap();
            }

            if(pthread_create(&comm_thd, &my_t_attr, extde_comm,  NULL) != 0)
            {
                printf("FAIL to create thread\n");
                close_ap();
            }

____________________________________________________________
GET FREE 5GB EMAIL - Check out spam free email with many cool features!
Visit http://www.inbox.com/email to find out more!



Reply to: