Skip to content

Instantly share code, notes, and snippets.

View aagontuk's full-sized avatar

Ashfaqur Rahaman aagontuk

View GitHub Profile
@juniorprincewang
juniorprincewang / get.c
Last active March 21, 2022 23:30 — forked from garcia556/get.c
POSIX shared memory IPC example (shm_open, mmap), working on Linux
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#define STORAGE_ID "/SHM_TEST"
#define STORAGE_SIZE 32
int main(int argc, char *argv[])
@MattPD
MattPD / analysis.draft.md
Last active May 4, 2024 14:56
Program Analysis Resources (WIP draft)
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active May 4, 2024 05:06
set -e, -u, -o, -x pipefail explanation
@plusk01
plusk01 / taskset_example.md
Last active February 14, 2023 20:43
Understanding CPU affinity with taskset

CPU Affinity

In a single core system, the OS allows multiple processes to run by sharing CPU time with the multiple processes. This is called concurrency, which gives the illusion of multiple processes executing at once, but is in fact just using a scheduler to give each process dedicated time on the CPU. The time associated with switching processes on a single core is overhead caused by context switching.

When a multi-core processor is available to an OS (e.g., Linux), the scheduler will do its best to allow processes to run simultaneously (by placing processes on different cores) in addition to running concurrently (different processes on the same core).

To control which core a process runs on, we can tell the scheduler to give a process a certain affinity towards a given set of CPUs.

Using taskset, we can get/set the CPU affinity of a particular process. Consider the following example.

@githubfoam
githubfoam / Mellanox OFED cheat sheet
Last active April 1, 2024 07:32
Mellanox OFED cheat sheet
--------------------------------------------------------------------------
# ofed_info -s
--------------------------------------------------------------------------
Find Mellanox Adapter Type and Firmware/Driver version
ConnectX-4 card
# lspci | grep Mellanox
0a:00.0 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3]
# lspci -vv -s 0a:00.0 | grep "Part number" -A 3
# lspci | grep Mellanox | awk '{print $1}' | xargs -i -r mstvpd {}
@zuyu
zuyu / ubuntu-install-gcc-6
Last active May 3, 2024 06:57
Install gcc 6 on Ubuntu
sudo apt update && \
sudo apt install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
sudo apt update && \
sudo apt install gcc-6 g++-6 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 && \
gcc -v
@rueycheng
rueycheng / GNU-Make.md
Last active April 29, 2024 01:39
GNU Make cheatsheet
@sloanlance
sloanlance / Editing remote files in Vim with SSH.md
Created July 13, 2017 16:11
Editing remote files in Vim with SSH

Editing remote files in Vim with SSH

  1. Configure SSH

    In ~/.ssh/config, include the lines:

    Host *
    ControlPath ~/.ssh/sockets/%r@%h-%p
    
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active May 2, 2024 16:19
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@r00tdaemon
r00tdaemon / Install PyQt5 on Ubuntu with python3 .md
Last active May 4, 2024 04:08
Install PyQt5 on Ubuntu with python3. Steps to set up PyQt5 (ubuntu). With python code generation

Installation

pip3 install --user pyqt5  
sudo apt-get install python3-pyqt5  
sudo apt-get install pyqt5-dev-tools
sudo apt-get install qttools5-dev-tools

Configuring to run from terminal