Setting sched. policy & pulse value

bridged with qdn.public.neutrino
Post Reply
Polczer Eszter

Setting sched. policy & pulse value

Post by Polczer Eszter » Tue Oct 21, 2003 7:41 pm

Hi!

I have 2 questions:

1. How can I set a thread sched. policy to RR?
2. A pulse can carry a 32 bit value. It can be a data with _Uint32t type,
isn't it? How can I access to this value from that thread, which receives
the pulse?

I hope somebody can help me! Shall I get code examples, too?

Thanks!

Eszter

Dmitri Poustovalov

Re: Setting sched. policy & pulse value

Post by Dmitri Poustovalov » Wed Oct 22, 2003 9:03 am

AGB wrote:

Polczer Eszter wrote:

Hi!

I have 2 questions:

1. How can I set a thread sched. policy to RR?

pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setschedpolicy(&attr,SCHED_RR);//... (online help).
// add this one also
pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);

2. A pulse can carry a 32 bit value. It can be a data with _Uint32t type,
isn't it? How can I access to this value from that thread, which receives
the pulse?


The pulse value and code can be acessed using:
int rcvid,chid,code,value;
union _msg{
struct _pulse pulseinfo;//stores data if a pulse.
char messagedata[80];//stores data if a message.
}msg;
struct _msg_info msginfo;

...setup stuff here... (ie open connection).

rcvid=MsgReceive(chid,&msg,sizeof(msg),&msginfo);
if(rcvid==0){//pulse
code=msg.pulseinfo.code;
value=msg.pulseinfo.value.sival_int;
//msg.pulseinfo.value is actually a union of an int and pointer.
Now do stuff with code and value...
}

AGB

Re: Setting sched. policy & pulse value

Post by AGB » Wed Oct 22, 2003 9:52 am

Polczer Eszter wrote:
Hi!

I have 2 questions:

1. How can I set a thread sched. policy to RR?
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setschedpolicy(&attr,SCHED_RR);//... (online help).
2. A pulse can carry a 32 bit value. It can be a data with _Uint32t type,
isn't it? How can I access to this value from that thread, which receives
the pulse?
The pulse value and code can be acessed using:
int rcvid,chid,code,value;
union _msg{
struct _pulse pulseinfo;//stores data if a pulse.
char messagedata[80];//stores data if a message.
}msg;
struct _msg_info msginfo;

....setup stuff here... (ie open connection).

rcvid=MsgReceive(chid,&msg,sizeof(msg),&msginfo);
if(rcvid==0){//pulse
code=msg.pulseinfo.code;
value=msg.pulseinfo.value.sival_int;
//msg.pulseinfo.value is actually a union of an int and pointer.
Now do stuff with code and value...
}

Post Reply

Return to “qdn.public.neutrino”