c++ postfix not working

C++ postfix not working?
I have an integer called:

int pID = 0;

Inside my while loop I'm using pID++; to increment it. Sometimes the pID doesn't get incremented and sometimes it will. My sample output would be.

0
1
2
2
2
3
4
5
5
6
7

Does anyone have an idea to why it would be doing this?


Here is the code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
int main(int argv, char *argc[])
{
  srand(time(NULL));
  totalRunningTime = clock();
  int randomP;
  int pID = 0;
  int ran = 0;
  int tempA;
  FILE * filePt;


  while(true)
  {
    randomP = rand() % 2;
    pID++;
    printf("%i\n",pID);
    if(randomP == 0)// Creates a process
    {
      queue(pID,0,0);
    }

    tempA = q[head].getAffinity();
    if (q[head].getPID() > -1)// give cores a process
    {
  
      switch(tempA)
      {
        case 0:CPU(tempA);
        case 1:CPU(tempA);
        case 2:CPU(tempA);
        case 3:CPU(tempA);
      }
    }
    //S; //sleep
    // Determine process fate
    ran = rand() % 3; 
    switch(ran)
    {
      case 0: killProcess(); // process terminates and is removed from the system.
      case 1:
    {
      if(isQueueEmpty() == 0)// Make sure queue isn't empty
        queue(pop());//1 – process returns to the ready queue to wait its turn
    }
    case 2:
    {
      if(isQueueEmpty() == 0)// Make sure queue isn't empty
        io(pop());//2 – process requires I/O and goes into the I/O queue.
    }
   }

  }
  return 0;
}
what does queue do? does it print the pID value?
The problem was somewhere else in my code. I was forking off parents instead of children, and this was causing multiple parents to run in the background. I fixed the code and now it's working.
Topic archived. No new replies allowed.