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
Setting sched. policy & pulse value
Re: Setting sched. policy & pulse value
AGB wrote:
pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
// add this one also
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).
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...
}
Re: Setting sched. policy & pulse value
Polczer Eszter wrote:
pthread_attr_setschedpolicy(&attr,SCHED_RR);//... (online help).
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...
}
pthread_attr_init(&attr);Hi!
I have 2 questions:
1. How can I set a thread sched. policy to RR?
pthread_attr_t attr;
pthread_attr_setschedpolicy(&attr,SCHED_RR);//... (online help).
The pulse value and code can be acessed using: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?
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...
}