State whether the following statement is True or False with reason for your answer: Coroutine is just another name for a subroutine.

GATE 1994 · Compiler Design · Assembler · medium

Answer: FALSE. Coroutines are NOT the same as subroutines. A coroutine can be suspended and resumed at multiple points, whereas a subroutine always executes from start to finish before returning control.

  1. Properties of a subroutine: A subroutine has a single entry point. When called, it executes from beginning to end and then returns. The caller always waits for the subroutine to complete. The relationship is asymmetric (master-slave).
  2. Properties of a coroutine: A coroutine can be suspended at any point using a 'resume' or 'yield' operation. When another coroutine resumes it, execution continues from where it was suspended, not from the beginning. Two coroutines can call each other symmetrically — neither is strictly the 'master'. This enables cooperative multitasking patterns like producer-consumer.
  3. Conclusion: Since a coroutine can be suspended and resumed multiple times (multiple entry points), while a subroutine always starts from its beginning and runs to completion, they are fundamentally different. Coroutines generalize subroutines. The statement is FALSE.