producer-consumer problem

The intention of the program. Create N threads with 2 shared memories.
One shared memory to write, one shared memory to recieve.
Consumer creates 2 shared memory to share with producer.
I need H threads for the producer as well(somebody help on it..)
Also another question, would segment_id variable interfere with each other in threads?

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/shm.h>
#include <string.h>
#include <pthread.h>
#define N 10
#define H 20
pthread_t house[N];
struct message
{
               char text[10];
               int source;
                int destination;
};

void *hovig(void *param)
{
                        struct message m1;
                        int segment_id;
                        int segment_id1;
                         int size = 60;
                        struct message *shared_memory;
                        struct message1 *shared_memory1;
                        segment_id = shmget(IPC_PRIVATE,size,S_IRUSR | S_IWUSR);
                       shared_memory = (struct message *)  shmat(segment_id,NULL,0);
                        segment_id1 = shmget(IPC_PRIVATE,size,S_IRUSR | S_IWUSR);
                       shared_memory1 = (struct message *)  shmat(segment_id1,NULL,0);

                      return  (void*)(size);
}

int main()
{
                        int value = 4;
                         int i = 0;
                      for(i = 0; i < N; i++)    
                            pthread_create(&house, NULL,&hovig, &(value));
                    
                      pthread_join(house,NULL);
}

why you use shared memory in thread programming?
pthread_cond_wait + pthread_cond_signal + pthread_mutex_lock + pthread_mutex_unlock will work fine.

producer                                                     consumer
-----------------------------------------------------------------------------------
pthread_mutex_lock ()                       |   pthread_mutex_lock ()
while (total == buffer length)              |   while (total < 1) 
   pthread_cond_wait (less condition)   |       pthread_cond_wait (more condition) 
put_to_buffer ...                              |   get_from_buffer  ....
pthread_cond_signal (more)               |   pthread_cond_signal (less)
pthread_mutex_unlock ()                   |   pthread_mutex_unlock ()

what if i use semget semop and not use pthread_mutex_lock..
shall it work?