top of page

Processes

Tutoring Operating Systems and Networks > Processes

​A process is an instance of a computer program that is currently being executed. It contains the program code and it's current activity.

Depending on the operating system, a process could be made of multiple threads of execution that execute concurrently. This allows tasks to be performed alongside each other. 

 

A program is just a passive set of instructions until it is executed. This creates an instance of it. So if you open a program several times, there will be multiple processes associated with the same program. 

 

Multitasking allows processors to switch between tasks that are being performed without waiting for each task to finish. This is desirable as otherwise, tasks would have to be fully completed before moving on to the next one which would slow everything down.

 

Time sharing is a way to allow multiple user to operate on the same computer. Several tasks can be kept simultaneously in memory. Because processes usually only run for a short time before needing to access I/O (very slow) or finishes, keeping tasks accessible like this speeds up perforrmance.

 

Batch processing invloves queueing up programs to execute so that there are no "dead period" waiting around for them to load. 

 

Threads

 

A thread of execution is the smallest sequence of programmed instructions that can be managed independently by an operating system scheduler. In most cases, a thread is contained within a process. Multiple threads can share the same resources such as memory, in contrast, multiple processes do not share resources. Multiple threads can be run on a single processor by implementing line switching (time-division multiplexing).

 

Why are threads desirable?

  • Frugality - threads share resources so save memory. They are also small compared with processes in terms of initital creation.

  • Responsiveness - Because of multithreading, we don't have to wait for a process to finish to start the next one.

 

Why not?

  • Deadlock - sharing resources can be tricky as threads may try to access resources at the same time. If you had 3 threads all waiting for each other to finish before each can proceed, this is called deadock. If you have a high-concurrency situation, this might be more likely than not. There are ways to fix this problem, for example, by introducing a round-robin style system where each thread waits a specified time for other threads to finish and threads sometimes pull back so they cannot hog resources. A thread that hogs resources is called a greedy thread.

 

APIs
  • Application programming interfaces (APIs) are software that specifies how software components interact with each other. They basically make the job easier for the programmer and usually comes with a collection of libraries with pre-defined specifications of sub-routines, data structures and instructions. 

  • Some APIs are necessary in order for programmers to interact with certain software components.

  • In object oriented programming, an API is generally a collection of classes and a prescription of how they should interact with each other. With most object oriented languages, you also get a description of a set of class definitions with a set of behaviours associated with those definitions. 

  • APIs are also useful as they allow programs to compile and run on any system that supports that API. This is called portability.

bottom of page