programming

Synchronization

April 4, 2021 | os, osdev, programming, synchronization

tags Operating Systems Programming Computer Science Notes from the Little book of Semaphores (Downey 2008). Shared variables # Many applications enforce the constraint that the reader should not read until after the writer writes, this is because the reader may read an old value if the writer hasn’t written to the variable yet A thread may also interact as concurrent writes (two or more writers) and concurrent updates (two or more threads performing a read followed by a write) Think about what paths (execution paths) are possible and what are the possible effects. ...

C pointers

February 12, 2021 | c, programming

tags Programming Computer Science For understanding how pointers work, consider the following simplified memory layout. the memory address starts in 0x1 and goes up to address 0xA. The value row holds the current data stored in that memory cell. Address 0x1 holds a pointer to address 0x6, which in turn 0x6 holds the value s. Address 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA Value 0x6 s e d s \0 Variable name hostname hostname hostname + 1 hostname + 2 hostname + 3 hostname +4 . ...

Modeling C-based systems with UML

November 14, 2020 | programming, c, methodologies

tags Software Engineering Methodologies Introduction # The Unified Modeling Language (UML) is used almost exclusively for Object Oriented Programming (OOP). Since embedded system design has become increasingly more complex, designers have been searching for new methodologies to manage these complexities and allowing higher productivity. Due to the exclusivity of UML for OOP, it makes it difficult for functional programmers to integrate UML concepts into the modeling because the transformation of many UML concepts to C is difficult and confusing (Wang 2009). ...

Technical challenge checklist

October 16, 2020 | programming, checklist

tags Programming Software Engineering Having done quiet a lot of technical challenges, and having forgotten some details when submitting, I came up with a good checklist of things to check before submitting the technical test. Must do checklist # Keep commit readable, check if the company has any commit format of their own in their public GitHub organization or their wiki page (if any), otherwise, use conventional commits Structure your commits so we can revert in case of any bug. ...

Go binary search tree

September 7, 2020 | go, algorithms, programming

tags Go Programming Software Engineering Requirements # Sorted array of lenght N Performance # Say an array contains N (search space o N) elements, and we divide N/2, getting a search space of N/2, how many steps do we need until we get down to just one an array of 1 element. O(log2 n) problem. Implementation # Can be implemented recursively or non-recursively. ...

Go Context package

September 3, 2020 | go, programming

tags Programming Go Programming Keywords # Cancellation: is when you are requesting some services, and you cancel this request Propagation: means that if we asked someone for a service then you tell that person to cancel

Python temporary file

August 2, 2020 | python, programming, libs

tags Python Programming Python’s tempfile standard library is pretty neat when we need to create a temporary file and/or directories. Instead of having a much of code like this: import pathlib def create_file(filename): if pathlib.Path(filename).exists(): # handle path removal/rewrite/backup pass with open(filename, "w") as f: # write to file pass We can ask Python to take care of handling this type of tasks for us. tempfile handles most of the OS API, so we can focus on writting the logic instead. ...

Python Async

July 30, 2020 | python, programming

tags Python Programming Important keywords # Asynchronous IO (async IO) Language-agnostic paradigm (model) coroutine A Python (sort of generator function) async/await Python keywords used to defined a coroutine asyncio Python package that provides an API for running/managing coroutines Coroutine # A coroutine allows a function to pause before returning or indirectly call another coroutine for some time, for example: import asyncio import time async def count(n): print(f"n is {n}") await asyncio. ...