Setting sched. policy & pulse value

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

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);


  1. 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…
}

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).

  1. 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…
}