Notes, summaries, assignments, exams, and exercises for Computer science for University

Network Congestion Control and Traffic Shaping

Computer science6 KB

Network Layer Design Issues

The network layer involves several critical design considerations, including store-and-forward switching, transport-layer services, the distinction between Virtual Circuits (VC) and Datagrams, and congestion management.

Understanding Network Congestion

Congestion occurs when too much traffic enters the network, leading to overloaded routers and a sharp drop in overall performance.

Congestion Control vs Flow Control

  • Congestion Control: A global issue involving all routers and hosts to manage total network load.
  • Flow Control: A point-to-point mechanism ensuring a sender does not overwhelm a specific receiver.

General Principles of Congestion Management

  1. Monitor the system to detect where and when congestion occurs.
  2. Distribute
...
Continue reading "Network Congestion Control and Traffic Shaping" »

Python Classes, Objects, and Inheritance Fundamentals

Computer science4.11 KB

Understanding Objects in Programming

An object is a software entity that contains data (attributes) and methods. It represents a real-world entity that can be distinctly identified.

Every object has a unique:

  • Identity: The name of the object (e.g., the variable name).
  • State: The data stored in the object, which defines its properties.
  • Behavior: The actions an object can perform, defined by its methods.

Can an object be passed as an argument to a function?

Yes. In Python, objects are passed by reference. This means any changes made to the object's attributes within the function will permanently alter the original object. This behavior is similar to how lists and dictionaries are handled. Think of it as sharing a key to a single locker rather than getting...

Continue reading "Python Classes, Objects, and Inheritance Fundamentals" »

Microprocessor vs. Microcontroller: Understanding the Key Differences

Computer science2.45 KB

Microprocessor vs. Microcontroller

ii) Differentiate Between a Microprocessor and a Micro-Controller

Microprocessor

Definition:

A microprocessor is a central processing unit (CPU) on a single integrated circuit (IC) chip that performs the processing functions of a computer.

Functionality:
  • It only includes the CPU core and lacks other components like memory, I/O ports, timers, and other peripherals.
  • Requires external components like memory (RAM, ROM), input/output devices, timers, and other peripherals to function as a complete system.
Usage:
  • Primarily used in systems requiring high computational power and flexibility, such as desktop computers, laptops, servers, and high-end embedded systems.
  • Suited for applications where customization of peripherals
...
Continue reading "Microprocessor vs. Microcontroller: Understanding the Key Differences" »

Software Engineering Core Concepts: SDLC, Architecture, VCS

Computer science5.66 KB

Software Engineering Fundamentals and Principles

Desired Software Attributes

  • Maintainability
  • Dependability
  • Efficiency
  • Usability

Major Challenges in Large Programming

  • Complexity
  • Change

The 5 C's (Collaboration Framework)

Key elements often cited in successful team environments:

  • Collaboration
  • Communication
  • Coordination
  • [Note: The original source implies additional C's beyond the listed three.]

Core Activities of Software Engineering (SE)

  • Defining
  • Managing
  • Describing
  • Designing
  • Implementing
  • Testing
  • Deploying
  • Maintaining

The 4 P's of Software Engineering

  • People
  • Process
  • Project
  • Product

Software Development Lifecycle Phases (SDLC)

  1. Requirements Planning
  2. High-Level Design (Architecture Design)
  3. Low-Level Design
  4. Development (Implementation)
    • Note: Unit testing is typically performed during
...
Continue reading "Software Engineering Core Concepts: SDLC, Architecture, VCS" »

C Synchronization: Semaphores for Process Control

Computer science5.09 KB

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/sem.h>
#include <sys/wait.h>
#include <sys/time.h>

define DELAY_MICROSECONDS 1000 // Renamed ESPERA for clarity

int initialize_semaphore(int value); int operate_semaphore(int semaphore, int operation); int remove_semaphore(int semaphore); int semaphore_wait(int semaphore); // Corresponds to P operation int semaphore_signal(int semaphore); // Corresponds to V operation void execute_command(int semaphore, char* command); void custom_delay();

int main() { int sem = initialize_semaphore(1); if (sem == -1) { fprintf(stderr, "Failed to initialize semaphore.\n"); return 1; }

execute_command(sem, "clear");
execute_command(sem, "date");
execute_
...
Continue reading "C Synchronization: Semaphores for Process Control" »

Understanding Operating Systems: Traps, Interrupts, System Calls, and Threads

Computer science3.94 KB

What is the Key Difference Between a Trap and an Interrupt?

A trap is caused by the program and is synchronous with it. If the program is run again and again, the trap will always occur at exactly the same position in the instruction stream. An interrupt is caused by an external event and its timing is not reproducible.

Why is the Process Table Needed in a Timesharing System?

The process table is needed to store the state of a process that is currently suspended, either ready or blocked. It is not needed in a single-process system because the single process is never suspended.

Is the Process Table Needed in Personal Computer Systems With Only One Process?

No, it is not needed in a single-process system because the single process is never suspended....

Continue reading "Understanding Operating Systems: Traps, Interrupts, System Calls, and Threads" »

Understanding Virtual Machines and Operating Systems

Computer science2.67 KB

Virtual machines are software that emulates a computer and can run programs like a real computer. This software was initially defined as "an efficient, isolated duplicate of a physical machine." The meaning of the term now includes virtual machines that have no direct equivalence with any actual hardware.

Understanding Shells

A shell is a piece of software that provides an interface for users. Usually, the term refers to the operating system shell that provides access to kernel services. The operating system shells generally fall into two categories according to their interface:

  • Command Line Interface (CLI)
  • Graphical User Interface (GUI)

Multiprogramming vs. Monoprogramming

Multiprogramming allows two or more processes to run in the same unit of

...
Continue reading "Understanding Virtual Machines and Operating Systems" »

Page Replacement Algorithms and Thrashing Explained

Computer science2.49 KB

Page Replacement Algorithms

  • Random: The least efficient method, though simple to implement.
  • FIFO (First-In, First-Out): Replaces the page that has resided in real memory the longest. It is easy to implement using a list to track page order.
  • LRU (Least Recently Used): Replaces the page that has not been referenced for the longest period. It is highly effective because past behavior is often a reliable indicator of future needs.
  • NUR (Not Used Recently): Selects a victim page cyclically, specifically targeting pages that have not been accessed or modified within a recent time window.
  • LFU (Least Frequently Used): Replaces the page with the lowest reference count. This requires maintaining reference counters for each page.
  • The Clock: A variant of LRU
...
Continue reading "Page Replacement Algorithms and Thrashing Explained" »

Operating System Memory Management: Paging and Segmentation

Computer science3.19 KB

Page Fault Handling

  • Hardware triggers the trap and saves the Program Counter (PC).
  • The trap handler (interrupt routine) saves the registers.
  • The OS detects a page fault.
  • The OS searches for a free page frame. If none are available, it selects a victim page and evicts it.
  • The OS initiates I/O for the page that triggered the fault.
  • Once the disk interrupt handler notifies that the page has arrived, the process is scheduled for execution again.

Page Table Management

During each context switch, the current page table must be saved in the Process Control Block (PCB) and the new process's table must be loaded. Tables can be stored in:

Registers

  • Provides faster access.
  • If there is significant RAM, the table will have too many entries to fit in registers.
  • Every
...
Continue reading "Operating System Memory Management: Paging and Segmentation" »

Dining Philosophers Problem: C Implementation with Pthreads

Computer science2.22 KB

C Implementation of the Dining Philosophers Problem

This program simulates the Dining Philosophers problem using C and Pthreads to demonstrate concurrency and synchronization concepts.

Global Variables

  • num_filosofos (int): Number of philosophers.
  • seed (int): Seed for random number generation.
  • holders (pthread_mutex_t*): Array of mutexes representing forks.
  • timeIni (long): Initial time in milliseconds.

Functions

long dameTiempo()

Returns the current time in milliseconds.

int eat(int n)

Simulates a philosopher eating.

  • TimeWait (long): Random wait time (0-500 ms).
  • Prints a message indicating the philosopher is eating.
  • Waits for TimeWait milliseconds.
  • Releases the left and right forks (mutexes).

int sleep(int n)

Simulates a philosopher sleeping.

  • TimeWait (long):
...
Continue reading "Dining Philosophers Problem: C Implementation with Pthreads" »