GATE CS 2025 Set 1 | Question 29

Operating Systems › Introduction & Process Management · NAT · 1 mark · Answer: 21

  1. Question 29Operating Systemsnat1 mark
    Suppose in a multiprogramming environment, the following C program segment is executed. A process goes into I/O queue whenever an I/O related operation is performed. Assume that there will always be a context switch whenever a process requests for an I/O, and also whenever the process returns from an I/O. The number of times the process will enter the ready queue during its lifetime (not counting the time the process enters the ready queue when it is run initially) is _______. (Answer in integer)
    int main()
    {
        int x=0,i=0;
        scanf("%d",&x);
        for(i=0; i<20; i++)
        {
            x = x+20;
            printf("%d\n",x);
        }
        return 0;
    }

    Answer: 21

    Solution

    Answer: 21 Each I/O operation causes the process to move to the I/O queue; when the I/O completes, the process returns to the ready queue. So the process re-enters the ready queue once per I/O operation (the initial entry is excluded by the question). I/O operations here: - scanf → 1 I/O. - printf inside the loop, executed 20 times → 20 I/O. Total re-entries .

More GATE PYQ on Introduction & Process Management

All GATE CS Operating Systems PYQ →

Attempt GATE CS 2025 Set 1 in real GATE exam mode

Full paper with a timer, the GATE interface and a topic-wise analysis — free.

Create free account →