hi,
I'm running a C program on Linux PC. It creates a Message Queue and sends data into it using msgsnd. I've another program which is as follows:

// appropriate header files included

#define MQ_KEY xxx

typedef struct msgbuf {
long mtype;
char mtext[1024];
} message_buf;

int a[1024];
message_buf *rbuf;
int noBytes;

void *f1(void *)
{
int mqId,res,i;

mqId = msgget(MQ_KEY, 0666);
rbuf = (struct msgbuf *)malloc((unsigned)(sizeof(struct msgbuf)) );
while(1)
{
noBytes=msgrcv(mqId, rbuf, 1024, 1, 0);
sleep(1);
}
return NULL;
}

void *f2(void *)
{
while(1)
{
memcpy(a,rbuf->mtext,noBytes);
memset(a,0,sizeof(a));
memset(rbuf->mtext,0,sizeof(rbuf->mtext));
sleep(1);
}
return NULL;
}

int main()
{
pthread_t th1;
pthread_t th2;

pthread_create(&th1,NULL,f1,NULL);
pthread_join(th1,NULL);
pthread_create(&th2,NULL,f2,NULL);
pthread_join(th2,NULL);

return 0;
}

Now, when msgrcv() blocks waiting for the message, will the thread f2() be called to run? I see this happening. will thread switching happens when msgrcv() is blocked?