What i want to do>>> in prodcon.c>>>
The producer should be configurable using command line arguments such that:
The maximum number of jobs that the system can handle is specified.
The maximum number of jobs that will be created by the producer during each cycle.

What i want to do >>>in conprod.c>>>
The process should be configurable using command line arguments such that the maximum number of jobs to be deleted during each cycle can be specified.
It should perform the following functions:

1. Find and delete a number of printer jobs by priority order.
2. Print a message to notify the user of the deletion.
3. Kill the corresponding process.
4. Remove the process’s details from the data structure.

here is my code..my head is spinning right now I could not access the data from producer and my code does not run properly. your help will be much appreciated.!!

prodcon.c
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/shm.h>
#include <time.h>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#define size 10


struct pro
{
int PID[10];
int PRI;
};




int main(void)
{
int nCount,i,items;
int SHARED_MEM;
key_t SHARED_KEY = 5678;
pid_t pid;


struct pro* ptr;
//ptr = (struct pro*)malloc(sizeof(struct pro)*10);


/* creating shared memory block */
    SHARED_MEM = shmget(SHARED_KEY, 10*sizeof(struct pro), IPC_CREAT | 0666);
//shm = shmat(SHARED_MEM,NULL,NULL);


if(SHARED_MEM<0)
    {
        perror("shmget");
        exit(1);
    }
    printf("Segment created\n");


/*attach the segment to the data space and use it for created structure*/


    ptr = (struct pro*) shmat(SHARED_MEM, (void *)0, 0);
//ptr = shmat(SHARED_MEM,0,0);




int flag=1;




srand(time(NULL));


printf("how many items to produce: ");
scanf("%d",&items);


while(flag != 2)
{


for(nCount =0;nCount<items;nCount++)
{
        pid = fork();
    if(pid<0)
{
    perror("error");
    exit(1);
}
    if (pid==0)
{
    while(1)
        {
            sleep(1);
        }
}
    if(pid>0)
{




    i = rand()%4;
    ptr->PID[nCount]=pid;
    ptr->PRI=i;
    printf("child pid is %d \t priority number is %d \n",ptr->PID[nCount],ptr->PRI);
if(items ==1)
    {
        flag =2;
    }
    items--;
//}
}
}
}






    return 0;
}


conprod.c

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/shm.h>
#include <time.h>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>


struct pro
{
char PID[10];
int PRI;
};




int main(void)
{
int nCount,i,items;
int SHARED_MEM;
key_t SHARED_KEY = 5678;
pid_t pid;






struct pro* ptr;




/* creating shared memory block */
    SHARED_MEM = shmget(SHARED_KEY, 10*sizeof(struct pro),0666);




if(SHARED_MEM <0)
    {
        perror("shmget");
        exit(1);
    }
    


/*attach the segment to the data space and use it for created structure*/


       ptr = (struct pro*) shmat(SHARED_MEM, (void *)0, 0);


printf("Items consumed: ");
scanf("%d",&items);
int size =10;
int values[size];
int strs[size];
int y,a;
for(y =0;y<items;y++)
{
values[y] = ptr->PRI;
ptr++;
}


for(a= 0;a<items;a++)
{
strs[a]=ptr->PID[a];
ptr++;
}




    int p=0;
    while(p<items)
    {
        int w=0;
        int min=100000,minpos=0;
        int mcount=0;
        
        while(w<y)
        {
            if(values[w]<min && values[w]>=0)
            {
                min=values[w];
                minpos=w;
                
            }
            if(values[w]<=0 || values[w]>100)
            values[w]=-1;
            if(values[w]==-1)
            {
                mcount++;
                
                
                
            }
            
            w++;
        }
        
       
       
       if(mcount==w)
        break;
        
        values[minpos]=-1;
         printf("data in priority:%d\n",strs[minpos]);
        
        p++;
        
    }




    
    /* remove the shared memory segment */
    /*if (shm_unlink(name) == -1) {
        printf("Error removing %s\n",name);
        exit(-1);
    }*/


    return 0;
}