Posts

Showing posts from September, 2015

Qt Object Thread Affinity

Image
Example code: https://drive.google.com/file/d/0BxorjNRCBW61ZEJhaEJST1RZa0k/view?usp=sharing For last whole year I have been totally lost between threads, mutexes, shared data, pointers, signals and slots and blah blah blah. Actually I have learned a heck of lot about all these things in these few months. But I think I haven't grasped everything yet. There are many combinations that I don't know work or not. And I think there are many other tricks I am yet to learn especially when it comes to debugging. Anyway, this post is about QThread and object affinity. Well, the typical QThread example is way too simple. They show an object containing one worker function and that worker function running in that thread when they start the thread. Beyond that, nothing! What happens if you call any function on that object, what happens? What about concurrency? What about when the thread is busy? Will the slots get queued up? Lots and lots of questions. But the r

sudo apt-get remove linux-image-3.13.0-4*

Image
*update: It worked!!! In a hurry to remove multiple old linux kernel versions from my system I popped in above command. After a while I came back to the terminal to find all my kernels were un-installed!!! :J Well, thankfully I noticed what has happened and right away reinstalled the latest one with this command: sudo apt-get install linux-image-3.13.0-62-generic. Haven't rebooted yet. Let see!

Qt global thread pool max thread count

Recently I encountered that some threads are not launching in our application using QConcurrentRun. If you launched the same worker function over QThread it was working.   So digging into this gave us this problem with defaults for Qt's global threadpool. Basically Qt sets global threadpool's max thread count to the no of cores you have on your processor. We were easily running out of the default four max threads. So we upped the count to 32 using following function:  QThreadPool::globalInstance()->setMaxThreadCount(32); We set this at start of the program in main. Things have been fine since then!

Remove BOM (Byte-order mark) from a file

Image
Got this script from following page: http://thegreyblog.blogspot.in/2010/09/shell-script-to-find-and-remove-bom.html #!/bin/bash set -o nounset set -o errexit DELETE_ORIG=true DELETE_FLAG="" RECURSIVE=false PROCESSALLFILE=false PROCESSING_FILES=false PROCESSALLFILE_FLAG="" SED_EXEC=sed USE_EXT=false FILE_EXT="" TMP_CMD="mktemp" TMP_OPTS="--tmpdir=" XDEV="" ISDARWIN=false if [ $(uname) == "SunOS" ] ; then   if [ -x /usr/gnu/bin/sed ] ; then     echo "Using GNU sed..."     SED_EXEC=/usr/gnu/bin/sed   fi   TMP_OPTS="-p " fi if [ $(uname) == "Darwin" ] ; then   TMP_OPTS="-t tmp"   SED_EXEC="perl -pe"   echo "Using perl..."   ISDARWIN=true fi function usage() {   echo "bom-remove [-adrx] [-s sed-name] [-e ext] files..."   echo ""   echo "  -a    Remove the BOM throughout the entire file.&q