Operating Systems Study Notes
What is an Operating System?
An Operating System (OS) is software that manages all hardware and software resources of a computer, acting as a central controller. Examples include Windows, Linux, and Android.
Main Functions of an OS
The main functions of an OS include Process Management (managing running programs), Memory Management (allocating RAM), File Management (handling files), Device Management (controlling I/O devices), and Security (protecting data and access).
Process Management
Process management involves the OS deciding which processes (running programs) get to use the CPU, when, and for how long.
Memory Management
Memory management is the OS's responsibility to determine which program uses which portion of the Random Access Memory (RAM).
File Management
File management encompasses the OS's role in creating, deleting, reading, and writing files on storage devices.
Device Management
Device management involves the OS controlling and coordinating the use of input and output devices such as keyboards, mice, and printers.
Security in OS
Security features in an OS protect data, manage login passwords, and enforce user permissions to prevent unauthorized access.
CPU Scheduling: FCFS
First-Come, First-Served (FCFS) is a CPU scheduling algorithm where processes are executed in the order they arrive, similar to a simple queue.
CPU Scheduling: SJF
Shortest Job First (SJF) is a CPU scheduling algorithm that prioritizes and runs the process with the smallest execution time first, aiming for the fastest completion.
CPU Scheduling: Priority Scheduling
Priority Scheduling assigns a priority level to each process, and the OS executes the process with the highest priority first.
CPU Scheduling: Round Robin
Round Robin is a CPU scheduling algorithm where each process is given a fixed time slice (time quantum) to run. If not completed, it goes to the back of the queue. This is common in multitasking systems like Android.
Deadlock Definition
A deadlock occurs when two or more processes are indefinitely stuck, each waiting for a resource held by another process in the cycle.
Conditions for Deadlock
Deadlock can occur if four conditions are met: Mutual Exclusion (resources cannot be shared), Hold & Wait (a process holds resources while waiting for others), No Preemption (resources cannot be forcibly taken away), and Circular Wait (a chain of processes waiting for each other).
Memory Management: Paging
Paging is a memory management technique where memory is divided into fixed-size blocks called pages, helping to avoid memory wastage.
Memory Management: Segmentation
Segmentation divides memory based on the logical parts of a program, such as Code, Data, and Stack.
Virtual Memory
Virtual memory allows the OS to use a portion of the hard disk (swap space) as an extension of RAM when the physical RAM is full.
What is Data Communication?
Data communication is the process of transferring data from one device to another, such as a mobile phone sending a message to a server.
Elements of Data Communication
The key elements of data communication are the Sender (initiates the message), Receiver (gets the message), Message (the data itself), Medium (the path for transmission, e.g., wire or wireless), and Protocol (the rules governing communication).
Transmission Modes: Simplex
Simplex mode allows data transmission in only one direction. An example is TV broadcasting.
Transmission Modes: Half Duplex
Half Duplex mode allows data transmission in both directions, but not simultaneously. A walkie-talkie operates in this mode.
Transmission Modes: Full Duplex
Full Duplex mode enables data transmission in both directions at the same time. A phone call is a common example.
Transmission Media: Guided
Guided transmission media, also known as wired media, include Twisted Pair Cable, Coaxial Cable, and Optical Fiber (which is the fastest).
Transmission Media: Unguided
Unguided transmission media, or wireless media, include Radio Waves, Microwaves, and Infrared.
OSI Model Layers
The OSI model consists of 7 layers: Physical (wires, signals), Data Link (frames, MAC address), Network (IP address, routing), Transport (TCP/UDP, reliability), Session (connection management), Presentation (encryption, formatting), and Application (user apps like browsers).
Number Systems
Common number systems include Binary (base-2, digits 0,1), Decimal (base-10, digits 0-9), Octal (base-8, digits 0-7), and Hexadecimal (base-16, digits 0-9 and A-F).
Logic Gates: AND
The AND logic gate outputs 1 only if all its inputs are 1.
Logic Gates: OR
The OR logic gate outputs 1 if at least one of its inputs is 1.
Logic Gates: NOT
The NOT logic gate inverts its input; if the input is 1, the output is 0, and vice versa.
Logic Gates: NAND
The NAND logic gate is the inverse of the AND gate; it outputs 0 only if all inputs are 1.
Logic Gates: NOR
The NOR logic gate is the inverse of the OR gate; it outputs 1 only if all inputs are 0.
Logic Gates: XOR
The XOR (Exclusive OR) logic gate outputs 1 only when its inputs are different.
Universal Gates
NAND and NOR gates are considered universal gates because any other logic gate or circuit can be constructed using only NAND or only NOR gates.
K-Map (Karnaugh Map)
A K-Map is a tabular method used to simplify Boolean expressions by grouping adjacent 1s in powers of two (1, 2, 4, 8).
Combinational Circuits: Half Adder
A Half Adder is a combinational circuit that adds two single bits and produces a Sum bit and a Carry-out bit.
Combinational Circuits: Full Adder
A Full Adder is a combinational circuit that adds three single bits (two input bits and a carry-in bit) and produces a Sum bit and a Carry-out bit.
Combinational Circuits: Multiplexer (MUX)
A Multiplexer (MUX) selects one of many input signals and forwards it to a single output line, based on control signals.
Combinational Circuits: Demultiplexer (DEMUX)
A Demultiplexer (DEMUX) takes a single input signal and routes it to one of many output lines, based on control signals.
Sequential Circuits
Sequential circuits are digital circuits whose output depends not only on the current input but also on the past sequence of inputs. They utilize memory elements like flip-flops.
Types of Flip-Flops
Common types of flip-flops, which are memory elements in sequential circuits, include SR, JK, D (most commonly used), and T flip-flops. Their state changes typically occur on a clock pulse.
Basic C Program Structure
A basic C program includes the header file inclusion (e.g., #include <stdio.h>) and the main function, which is the entry point of the program. The main function typically returns an integer (e.g., return 0;).
C Data Types: int
The 'int' data type in C is used to store whole numbers (integers).
C Data Types: float
The 'float' data type in C is used to store single-precision floating-point numbers (numbers with decimal points).
C Data Types: char
The 'char' data type in C is used to store single characters.
C Data Types: double
The 'double' data type in C is used to store double-precision floating-point numbers, offering a larger range and precision than 'float'.
Control Statements: if-else
The if-else statement in C allows for conditional execution of code. If a specified condition is true, the code block within the 'if' statement is executed; otherwise, the code block within the 'else' statement is executed.
Loops: for loop
The 'for' loop in C is used for executing a block of code a fixed number of times. It typically involves initialization, a condition check, and an update expression.
Loops: while loop
The 'while' loop in C repeatedly executes a block of code as long as a specified condition remains true. The condition is checked before each iteration.
Loops: do-while loop
The 'do-while' loop in C is similar to the 'while' loop, but it guarantees that the code block is executed at least once before the condition is checked.
Arrays in C
Arrays in C are used to store multiple values of the same data type under a single variable name. They are declared with a size, e.g., int arr[5].
Strings in C
Strings in C are sequences of characters terminated by a null character ('\0'). Common functions for string manipulation include strlen(), strcpy(), and strcmp().
Pointers in C
A pointer in C is a variable that stores the memory address of another variable. For example, if 'x' holds a value, 'p = &x' makes pointer 'p' store the address of 'x'.
Important C Programs
Key C programs to learn include those for calculating Factorial, generating Fibonacci series, finding the largest element in an array, summing array elements, checking for Palindromes, and reversing strings.
What is IoT?
The Internet of Things (IoT) refers to the network of physical devices embedded with sensors, software, and other technologies that enable them to connect and exchange data over the internet, allowing for automated communication and action.
IoT Architecture: Perception Layer
The Perception Layer is the first layer in IoT architecture, responsible for collecting data from the physical world using sensors and interacting with the environment through actuators.
IoT Architecture: Network Layer
The Network Layer in IoT architecture handles the transmission of data collected by the Perception Layer to other devices or platforms, utilizing various communication technologies like WiFi, Bluetooth, and Zigbee.
IoT Architecture: Application Layer
The Application Layer is the topmost layer of IoT architecture, where user-facing applications are implemented. These applications leverage the collected and processed data to provide services in areas like smart homes, smart agriculture, and smart health.
Common IoT Sensors
Common sensors used in IoT devices include Temperature sensors, Humidity sensors, Motion sensors, Infrared (IR) sensors, and Ultrasonic sensors, each designed to detect specific environmental parameters.
IoT Applications
IoT has numerous applications, including automating smart homes (controlling lights, AC), enabling smart farming for optimized crop management, improving efficiency in smart industries, and facilitating remote health monitoring.
Advantages of IoT
The advantages of IoT include saving time through automation, enabling seamless device interaction, improving overall efficiency, and providing real-time monitoring capabilities.
Disadvantages of IoT
Potential disadvantages of IoT include security risks due to increased connectivity, dependency on internet access, and potentially high initial costs for implementation.