Skip to content
Home Tutorials Roadmaps Courses
Log in Join free
Tutorials Computer Science OS Fundamentals
Computer Science Beginner FREE

OS Fundamentals

Lesson 1 of 17 Beginner Interactive

An operating system manages hardware resources and provides services for programs.

Key Functions

  • Process Management — scheduling, multitasking
  • Memory Management — allocation, virtual memory
  • File System — organizing storage
  • Security — access control

Syntax

COMPUTER-SCIENCE
# Process states
New → Ready → Running → Terminated
                ↓
              Waiting → Ready
Process Scheduling Concept
PYTHON
# Round Robin scheduling
def round_robin(processes, quantum):
    n = len(processes)
    remaining = [p[1] for p in processes]
    time = 0

    while True:
        done = True
        for i in range(n):
            if remaining[i] > 0:
                done = False
                if remaining[i] > quantum:
                    time += quantum
                    remaining[i] -= quantum
                else:
                    time += remaining[i]
                    remaining[i] = 0
                    print(f"{processes[i][0]} completed at t={time}")
        if done:
            break

processes = [("P1", 10), ("P2", 4), ("P3", 6)]
round_robin(processes, quantum=3)

Practice

1
Exercise

What are the main functions of an OS?

Answer
Process management, memory management, file system management, security, and I/O management.

Quick Quiz

1

What is multitasking?

Multitasking allows multiple processes to share CPU time.

Interview Questions

A process is an independent program with its own memory. A thread shares memory with other threads in the same process. Threads are lightweight.