Programming :: Preemption And Scheduling Of Pthreads
Feb 10, 2010
i think we can simulate preemption by using 2 different priority thread, am i true? I just try these scenario :
1. Create Thread A with priority 99 , SCHED_FIFO..
2. Create Thread B with priority 4 , SCHED_FIFO
Thread A started and doing some busy work.. I guess that Thread B wouldn't start until thread A finished, but I get thread B can run before Thread A finished (It just like a common task switching).. I'm sure my 2 thread has right priority. and if thread B is doing some work and if i yield it to thread A, it should preempt it but this doesnt happen, do someone kno wats happening?
View 1 Replies
ADVERTISEMENT
Jun 29, 2010
I just started with Pthreads and don't really know much about it. I want to suspend pthreads but apparently, there is no such function as pthread_suspend. but I don't understand why we need both mutex and condition to suspend and resume a pthread. Is it possible to suspend and resume it without using conditions?
View 1 Replies
View Related
Jun 14, 2010
I have confusion regarding pthreads return value. All in short, is the is a valid return value ?
[source]
void * myThrRoutine(void *arg)
{
struct myStruct **myst = (struct myStruct**) arg;
cout<<"In thread "<<(*myst)->var<<(*myst)->msg<<endl;
int x = 20;
pthread_exit((void*)x);
}
[/source]
This seems to work fine on pthread_join , but I want to ensure it is not by chance.
View 1 Replies
View Related
Mar 16, 2010
I am trying to write a peer to peer application in C++ using pthreads library. There are few types of nodes that run in the program. The 'beacon' nodes form the core of the network. The ordinary nodes 'join' the network by sending join requests to the beacon node. So, my program runs till the join requests and responses are received. When I try to 'connect' using connect function from the socket library, I get a segfault. I am not sure if the segfault occurs for the connect function, because sometimes the program just runs to completion. It could be an issue related to threads or memory allocation.
When I run gdb, it shows me the following:
Code:
(gdb) run b2-n00.ini
Starting program: sv_node b2-n00.ini
servant:12600> [New LWP 1]
[New LWP 2]
[New LWP 3]
[New LWP 4]
[New LWP 5]
[New LWP 6]
Before Exiting[LWP 1 exited]
procfs: fetch_registers, get_gregs line 3768, /proc/23952/lwp/1: No such file or directory.
View 6 Replies
View Related
Apr 14, 2011
I have a program that uses both Pthreads and OpenMP. Basically, 2 threads (Thread A and B) are created using Pthreads to do work, and in Thread A, OpenMP is used to parallelize a for loop.If I have a global variable that is accessed by the OpenMP threads and also Thread B, can I use the lock in OpenMP to ensure I have no race conditions?
View 2 Replies
View Related
Sep 17, 2010
I don't seem to find a conclusive answer to this one...."Is popen thread safe via pthreads?"
View 2 Replies
View Related
Feb 17, 2010
I have created two threads:
Thread 1 and thread 2
In the main thread, i have put up a timer which generates a signal periodically when it expires, which reults in execution going to signal catcher function.when this function is invoked, under certain condition it goes to thread 1 and under another condition it goes to thread 2. The problem lies here that when it goes to thread2,i have a loop to process but it doesnt come out of the loop and hence from thread2, even though timer has expired.
View 2 Replies
View Related
Mar 23, 2010
I have a program which is uses sigaction to register for a SIGIO signal (for incoming data on a fd) with an appropriate event handler. I also create a new detached thread 'B' that does some work with the received data. Normally the thread B runs properly. But when my event handler is called (because a there is new incoming data), after the event is handled, the thread B is not called immediately. There is a noticeable delay of the order of many seconds before it is scheduled again .During this delay, my program is doing nothing.
What am i doing wrong? Is there someway i can run thread B as soon as the event is handled (and assuming no other work is to be carried out)?
View 3 Replies
View Related
May 10, 2011
Does anyone know how to run 2 threads with round robin scheduling. & can we get the time of these threads when they are context switching. That means I want to know at how much time each thread is taking to run
View 3 Replies
View Related
May 4, 2011
I have a timer thread, and when it expires, it sets a flag. The only problem is, if any higher priority thread comes in between, then the timer is not expired in real time.Thus i want to set a highest priority to my thread. Now, i know 2 algos, which can make my thread in real time are: SCHED_FIFO and SCHED_RR.
So, here are my queries: 1) Which scheduling algo is best suited for this purpose? 2) Is it guaranted to work in real time if i use that algo (you suggest in 1) and set the max_priority by getting the maximum settable priority for that particular algorithm using, int sched_get_priority_max(int policy);
View 2 Replies
View Related
Sep 9, 2009
I am new to thread programming. I need to generate one thread in one process using posix thread. Which scheduling and priority do i need to use? I want to generate the thread with the lowest priority. As i know there are 3 scheduling policy available SCHED_FIFO, SCHED_RR or SCHED_OTHAR.
View 1 Replies
View Related
Jan 12, 2011
I am working on a large program in C to run on Puppy Linux. I have multiple pthreads running. I want to be able to set the pthread SCHED_POLICY and priority in my program but I want a user to be able to run the program without root privilege.
Using a sticky bit and root ownership gives the user too much power because they will be able to write and compile their own scripts. Is there a way to use 'sudo' when I set the thread parameters from my program or something like this?
View 1 Replies
View Related
Apr 6, 2011
I found in one thread a note about some kernel config parameters which should be used by servers.
Code:
config PREEMPT_VOLUNTARY
bool "Voluntary Kernel Preemption (Desktop)"
[code]....
View 14 Replies
View Related
May 21, 2010
I am playing around with pthreads. This program however blows up.
#include <iostream>
#include <pthread.h>
using namespace std;
struct myStruct
{
int a;
string msg;
};
void * myProc(void *arg)
{
struct myStruct* str = new struct myStruct();
str->a = 10;
str->msg ="hi";
return (void*)str;
}
int main(int argc, char **argv)
{
pthread_t mythr;
int status ;
void *retVal;
struct myStruct* m_str;
status = pthread_create(&mythr,NULL,myProc,NULL);
status = pthread_join(mythr,&retVal);
cout<<"Status is"<<status<<endl;
m_str = (struct myStruct*)m_str;
cout<<"retval is "<<m_str->a<<" "<<endl;
return 0;
}
Can a structure be returned by a thread as its return value ?
View 1 Replies
View Related
Jul 1, 2011
In my code I want to have two different functions to be executed simultaneously (in parallel) in a single processor system. I tried to use pthreads but they happened to be executed one after another. I have heard about fork, some saying that its no longer recommended since its functions can be achieved by pthreads.
View 1 Replies
View Related
Jan 9, 2011
I have a cron job to schedule the task on the third sunday of the month.I saw the previous threads but didn't find any solution.
How the cron syntax can be written.
View 14 Replies
View Related
Mar 10, 2010
We are seeing some strange behavior on a Set top Box with the scheduling of tasks. We use 2.6.12 kernel. The issue is when we create a Task, say task1 with a priority of 46.But,this task is not Scheduled to run by the scheduler right away. It gets chance to run only after sometime. What we see here is that I create many other tasks with lower priority than task1,but they are immediately scheduled. Ideally, the task1 should have got scheduled before certain other low priority tasks as it has higher priority. Any patch is available wrt this?
View 3 Replies
View Related
May 28, 2009
kindly give me example of earliest deadline first scheduling?
View 5 Replies
View Related
May 3, 2011
I want to change linux scheduling algorithm for some of my processes but when I click on processes in ksysguard and click renice project, all of the processes use normal level cpu scheduling. Why is it such a thing and there is no priority?
View 2 Replies
View Related
Apr 1, 2010
how can I use sar in order to get information about the scheduling?
View 1 Replies
View Related
Apr 16, 2010
what is disk scheduling and how does it work? and how is it done in ubuntu 9.1
View 2 Replies
View Related
May 5, 2010
I am wondering about scheduling audio playback under Ubuntu. The background is this: My birthday is fast approaching, and I always try to do something to remember the best birthday gift I ever received, that being the Apollo 11 mission; Neil and Buzz landed on my 12th birthday.
Anyway, I have a wagonload of audio from nasa.gov and would like to schedule the MP3s to play in real time. 'at' won't do it, at least with 'mplayer'; I've tried. I suspect that because there is no controlling terminal for jobs run under 'at', the audio has no place to go. Is there some way to get a controlling terminal for these audio playback jobs, or specify a destination to some player?
View 1 Replies
View Related
Mar 23, 2011
I can not get 'crontab' to work.Below is the results of 'crontab -e':
Code:
10 * * * * /usr/bin/sigrot
0 18 * * 5 /usr/bin/tff-meeting-mail.sh
[code]....
View 2 Replies
View Related
May 24, 2011
I was searching for many time but haven't found any solution. Cron would be great, but it allows only steps in range 1-59 minutes. Is there any mode to run something exactly every 73 minutes?
The second i need (the same problem) to run program little more than every 12 hours, it might be in steps of 12 hours and 4 minutes (but 13 hours is much too much).
View 4 Replies
View Related
Nov 24, 2010
Can anyone tell me where i can find patch for WFQ scheduling in ns2
View 3 Replies
View Related
Feb 11, 2011
i want to do scheduling using /etc/crontab file instead of using crontab -e that is crontab command on the terminal.i am appending to the crontab file in the /etc directory but the scheduling is not happening
View 7 Replies
View Related
Sep 8, 2010
is linux kernel is priority preemptive kernel?if it is. where it is using round robin scheduling algorithm?when processes are scheduled for the processor process will be allocated as which sechudling alogorithm?
View 1 Replies
View Related
Mar 10, 2011
iam try to schedule my job in a file made in /etc/cron.d file as follows* * * * * tomcat6 /home/etika/Desktop/eka.sh /home/etika/Desktop/ea/etika.txt abc@gmail.comwhere eka.sh belongs to etika which is the root and etika.txt belong to tomcat6 this command is not running iam confused about the name of the owner written after the *'s please tell me whose name is written after the *'s(the schedule of the script) the owner of the script or the owner of the file which iam passing as an argument to the shell script
View 2 Replies
View Related
Mar 10, 2011
I want to run a program at a precise second on a computer. I know cron can do it but I do not know how accurate it is. Is there a program so you can more precisely run a program at a defined time?
View 14 Replies
View Related
Nov 10, 2010
Some of you are probably not going to believe this, but I've been using Linux for like four years and have never used cron for task scheduling before. Now I want to and I'm not sure how to do it. Could somebody link me to some good info? The results of a Google search were kinda confusing.
View 5 Replies
View Related