Open In App

Difference between Routine and Process

Last Updated : 24 Jun, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we are going to discuss the difference between routine and process. Before differentiating between both, first, let us understand what they are.

Routine :
In computer programming, a routine is nothing but a sequence of code, intended for the execution of user programs and input/output operations. It can range from a subroutine, co-routine to a function. 
It is called repeatedly by other codes, during the execution of a program.

A routine, also known as a function with a specified programming interface, in higher-level languages, can be used in a program to perform a particular task many times, obviously with different data values.
Whenever a program needs to perform a specific task, the main sequence of logic in a program can branch off to a common routine when necessary. As soon as the routine has been executed, the calling program must resume the execution, by taking over the called routine. The called routine is said to return to the calling program, by executing the return instruction.

All these things are taken care of by the operating system internally, by means of a data structure known as Stack.

Example – 
A routine to multiply two numbers.

Process :
The process is a program in execution and represents the basic unit of CPU utilization.
A process is an active entity that is created when an executable file gets loaded into the main memory for execution. 
A system compromises a bunch of processes, some of which execute the system code(known as the operating-system processes) while, on the other hand, the rest of the processes that execute the user code(user processes).
Well, many students get confused with the terms Program and Process, but the two are different entities. The program is a passive entity, while the process is an active entity.
A process has numerous states, defined by the current activity of that process.
Each process is represented in the Operating System, by a Process Control Block(PCB).

Example –
The browser on which you are reading the article is actually a process in which multiple processes are running concurrently, maybe one for the UI, the other for the opened tabs.

Difference between Routine and Process :

  • A routine is a sequence of code, while a process is actually a code in execution.
  • A routine is used to perform a specific task and it can be a part of multiple processes.

The difference between Routine and Process in tabular form :

Criteria                                               

Routine

Process

Definition It is a sequence of code, intended for the execution of user programs and input/output operations. It is a program in execution, unit of work in modern time-sharing systems.
Role The role of a routine is to perform a task, and a routine can be called many a time by other routines or subroutines. Its role is to execute a sequence of code, it represents the basic unit of work to be implemented in a system.
Functionality It can be used in a program to perform a particular task many times. A process can be of two types, one which executes the system code, meanwhile, the other one being which executes the user code.
Example A routine to multiply two numbers, add two numbers, etc. called repeatedly. A calculator is a process responsible for doing several operations on an operand.

Like Article
Suggest improvement
Share your thoughts in the comments