C++ Concurrency and Utilities

I have been reading Bjarne Stroustrup’s “A tour of C++” recently and wanted to make notes on it’s last section: Concurrency and utilities Below are my notes. Resource Management It is important that a program doesn’t leak resources. This may cause security vulnerabilities, as much as program efficiency drop by orders of magnitude. To ensure resources are correctly used, we can handle them using the RAII (Resource Aquisition Is Initialization) technique.
Read more

C++ Container Mechanisms

Below are my notes on section 3 of “A tour of C++” Libraries The C++ standard library provides several facilities to the programmer, in order to simplify the given task. These include: Basic Runtime Language Support C standard Library Strings and I/O streams Framework of containers Support for numerical computation Support for REGEX matching Support for Concurrent processing Utilities to sopport template metaprorgamming Smart pointers Special-purpose containers Strings String concatenation is efficient given it has a move operator.
Read more

C++ Abstraction Mechanisms

I have been reading Bjarne Stroustrup’s “A tour of C++” recently and wanted to make notes on the different types of abstraction mechanisms available to the programmer. Below are my notes. Concrete Classes The basic idea of Concrete Classes is that they behave just like built-in types. It’s representation is part of it’s definition. This allows implementations to be optimally efficient in time and space. It defines the behavior of it’s member functions in full.
Read more

OSTEP - Scheduling Introduction

Scheduling is the policy we use to arrange the processes the CPU has to run and when. In this post, we are going to look into some basic scheduling techniques examples. Workload assumptions We are going to set a series of assumptions about the processes running in the system: Each job runs for the same amount of time All jobs arrive at the same time Once started, each job runs to completion All jobs only run on CPU (No I/O) The runtime of each job is known Scheduling metrics We are going to use these metrics to compare the different scheduling techniques.
Read more

OSTEP - Mechanisms Limited Direct Execution

There are many problems associated with virtualizing a CPU. The most important problem we have to solve is that we need to maintain control of the processes running, so they don’t take over the system. Other problems such as the need to switch environments and resources for every different process the CPU works on, also impact CPU efficiency. Basic Technique: Limited Direct Execution Direct execution: The Operating System provides access to the CPU directly to each process.
Read more

OSTEP - Virtualization - Processes API

Unix creates a process with a pair of system calls: fork() exec() A third system call can be used by a process to wait until a process it has created to complete. wait() fork() It is used to create a new process In the following example: #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char* argv[]) { printf("Hello world (pid:%d)\n", (int) getpid()); // rc = return code int rc = fork(); if (rc < 0) { // Fork failed fprintf(stderr, "Fork failed\n"); exit(1); } else if (rc == 0) { // Child (new process) printf("Hello, I'm a child (pid:%d)\n", (int) getpid()); } else { // Parent goes down this path printf("Hello, I am a parent of %d (pid:%d)\n", rc, (int) getpid()); } return 0; } A new child process is created when fork() is called.
Read more

OSTEP - Virtualization - Processes

This series contains my notes on the free on line book Operating Systems: Three easy pieces. As a user wants to be able to run multiple processes at once, we have to be able to create the illusion that there are as many processors as each program needs. The OS does this by virtualizing the CPU. (Executing instructions from one process and then changes to another program) This allows multiple programs to run at once.
Read more

Operating Systems - Three easy pieces - Introduction

This series contains my notes on the free on line book Operating Systems: Three easy pieces. I will create a entry on each topic or on anything I feel worth remembering/mentioning. This entry is the first one, consisting on a introduction to the book, and a few resources I found to be handy. Links and references XV6 Advanced XV6 OSTEP projects Main focus There are three main topics on operating systems development.
Read more

Rose-OS - Makefile teardown

In this post, I will be describing programs and resources used to build Rose-OS and how we combine then into a single, automated Makefile. Programs used to generate the kernel gcc nasm bochs (Emulator) ld cat rm gcc Is the compiler we use to compile our code. Normally, this command preprocesses, compiles, assembles and links our code, but we can stop it from doing this with some command-line options.
Read more

Photography Style

Abstract Generally, photography has been present in my life since I was a kid, now that I’m taking the craft more seriously, I’m starting to analyze my style amongst other things. This is a status update on the aforementioned topic. Background My father got me into photography. He always liked the art, but he is a very cathodic, deliberate photographer. If he had to define his style in one short sentence, it would be: “I deliberately take one good shot”.
Read more