Skip to main content

Posts

How to speed-up make-based building process

If you are building some multifile-based project using make tool, it is worth to use parallel build in order to speed up building process. You can do that using -j option  of make tool ex. make -j2 If you will select -j2, you are informing your compiler to use 2 cores of your CPU for building process. The optimal option is to split build using all cores of your CPU. In order to get number of cores of your CPU on Linux-based OS you can use command: nproc Therefore, if you would like to speed-up build time optimally using all cores of you CPU, you can use following command on Linux-based OS: make -j`nproc` Picture source: http://hostme.ie/wp-content/uploads/2011/03/speed-up-wordpress.jpg

Linux - VIM as Integrated Development Environment (IDE)

In this post I would like to present you my configuration of vim text editor as Integrated Development Environment (IDE). In my daily work I am not using big IDE environments like Eclipse, NetBeans or other. Instead, I am using vim text editor configured with number of plugins, which contains all of most important features of traditional IDE environment and additionally I don't need to resign with VIM advantages like speed and flexibility. Using that VIM as IDE configuration I comfortably work with following programming languages on the daily basis: C/C++ Java Python Bash JavaScript HTML CSS My VIM as IDE configuration is publically available in github. You can clone it from here: git clone https://github.com/xmementoit/vim-ide It is under continous development so you can expect adding new features in the future. Video presentation of main features of my VIM as IDE environment can be found on youtube: I am aware that starting with big VIM as IDE configurati...

Bash - useful bash aliases which I use in my daily work

~/projects/CppAdventureExamples/bash/aliases.html Bash alias is abbreviation of one terminal command (usually long command) using other terminal command (usually much shorter command). We can define aliases in bash dot files (ex. ~/.profile file). Example of bash alias: alias i="sudo apt-get install" Then we can install 'vim' package using 'i' alias this way (it works of Debian-based systems): i vim Today I would like to present few useful bash aliases which I use in my daily work. You can paste below aliases into your ~/.profile file (or ~/.bashrc) if you recognize them useful for you. Enjoy! #================================================================== # Listing aliases alias ll= "ls -lah" #list only directoriesj alias lsd= "ls -lF ${colorflag} | grep --color=never '^d'" alias sl= 'ls' #================================================================== #filter selected app fro...

Bash - parallel operations

Today I would like to present useful tool for every Linux developer - bash parallel mode. Bash parallel mode allows to invoke multiple bash tasks (ex. functions, linux applications etc.) in parallel, which could save time of processing them. What's is more, usage of bash parallel mode is very simple and does not require lot of work. Let's explain it based on the examples. We are starting with bash script working in seqence mode (one function invoked after previous one). We defind function task() which is later invoked in for loop 10 times. Invoking of each instance of function takes SLEEP_TIME=2 seconds. So script invokation takes 10x2s == 20 seconds. Now, lets change above script in order to work in parallel mode: Please note few small, but important changes between above scripts: < invokation of function task has '&' character at the end. It means that function will be invoked in background and will not block main thread of script. functio...

C++11 Multithreading - How to avoid race conditions

This article presents how to avoid problem of Race conditions described in this article. As we already know race conditions can occur when two or more threads are trying to invoke some part of code or use the same resource (ex. variable) at the time. That can cause problem of unexpected results. We could see that problem in 'Race conditions' article where two threads was able to modify the same variable value which caused different program output every time we invoked it. In order to avoid that problem we should synchronize operations of our threads using multithreading mechanism called mutexes (abbr. Mutual exclusion ). Mutex is some kind of program flow control lock which which is able to make sure that some part of code locked by itself can be invoked by only one thread at the same time. Such locked part of code is called critical section . When other thread will try to go into critical section it will be blocked and will need to wait until previous thread...

Software Adventure - new blog name

I decided to change name of this blog, because I am going to present not only C++ topics here. From today you can expect topics describing problems and features of following domains of software development: C++ programming language features, problems, issues C  programming language features, problems, issues Unix/Linux programming (ex. standard Linux C library, system calls etc.) Embedded Linux programming (problems and solutions related to Embedded Software Development) Software Development Design - Object Oriented Programming, Design Patterns etc. Software Development Life Cycle Sometimes I will also present some articles related to other programming languages like: Python, Java, JavaScript, HTML, CSS etc.  As you noticed range of topics in this blog has been significantly extended. It should this blog more interesting.

C++11 - User-defined literals

C++11 standard provides new way of customized literal constants called user defined literals . Thanks to that user can define own suffixes for standard literals (ex. digits) which defines it better and makes it better readable. Example of such suffixes could be: _meters, _kilograms, _squareMeters etc. For better understanding user-defined literals concept, let's take a look on the below example code: Output of that code is: In point one we can see concept of operator overloading function which should be used in order to define user-defined literals. In our example we are defining suffixex _meters and _squareMeters which will be used for imporve readability of code of calculations based on that units. Point II shows how we can use user-defined literals to assign values to variables. Such usage definitely makes code better readable and easier to understand. Point III, shows how we can use other suffix (_squareMeters) in comparison calculations. As we can see, our units a...