Reading List

The Selfish Gene
The Psychopath Test: A Journey Through the Madness Industry
Bad Science
The Feynman Lectures on Physics
The Theory of Everything: The Origin and Fate of the Universe


ifknot's favorite books »

Saturday, 11 July 2020

PiDP 11 ~/php.sh returns 0 Version GLIBC_2.28 not found



The latest version of smh for the PiDP11 requires glibc 2.8 unfortunately Raspbian stretch has version 2.4 and so your updated install of smh wil not work.

However, it is possible to update stretch to buster and this will solve the problem.

How to do this is a straight cut & paste from DDuck at
 https://www.domoticz.com/forum/viewtopic.php?t=30219

Let’s first update all the currently installed packages by running the following command.
CODE: SELECT ALL
sudo apt update
sudo apt dist-upgrade -y
Next, let’s go ahead and also update the Raspberry Pi’s firmware.
We can do that by running the command below on our Raspbian installation.
CODE: SELECT ALL
sudo rpi-update
Now that we have prepared our Raspbian Stretch installation, we can now start the process of moving to Buster.

Friday, 22 May 2020

Windows 10: Clean out unused COM ports


Do your COM ports look like this?

Then you've probably just discovered Windows is rubbish at handling USB COM port devices if you plug and unplug them willy-nilly.

How to clean out your COM port cruft:


  1. Run Command prompt with the elevated privileges.
  2. To enable device manager show absent device(s) enter devmgr_show_nonpresent_devices=1 
  3. Restart computer & Run Command prompt with the elevated privileges.
  4. Enter cd c:\Windows\system32 

  5. Enter devmgmt.msc
    (device manager is now running elevated and showing 'nonpresent' devices)
  6. In device manager activate the display of hidden devices from the top menu by clicking View > Show hidden devices.
    (This will list all devices including those that are no longerconnected)
  7. Expand the Ports (Com&LPT) section, all the COM ports that have ever been created will be displayed (the hidden and unused ones being in grey).
  8. Uninstall to your heart's content (right click, select Uninstall).


Tuesday, 28 April 2020

Undefined reference to operator delete(void*) C++ AVR pure virtual and __cxa_pure_virtual()

 __cxa_pure_virtual()
&
Undefined reference to operator delete(void*)


C++ Programming for MCUs such as the Atmel AVR family can be both very productive and also very frustrating as one learns to work without libstdc++ when using certain MCU toolchains e.g.
  • C++ AVR Studio 
  • C++ avr-gcc 
  • C++ Arduino 
Whilst it is generally well known that the MCU programmer must provide their own versions of new and delete[1] it is less well known that the C++ programmer using pure virtual member functions must provide an implementation for __cxa_purevirtual() or face some very confusing errors!

Depeding on toolchain the programmer may be lucky and be notified:

undefined reference to `__cxa_pure_virtual'

What is __cxa_purevirtual()?[2]

Friday, 13 December 2019

The Joy Programming Language #1

Functional Programming in Joy #1
Just because something is obscure does not make it unworthy of study.


What is Joy?

Joy is a pure, concatenative, functional, scalar programming language.
Joy is pure because it does not contain assignment.
Joy is functional because computation consists of the evaluation of expressions.
Joy is concatenative (and not applicative) because
  • The elementary well-formed expressions of Joy are monadic functions of a nameless data stack.
  • If X and Y are well-formed expressions, then the concatenation of X and Y is well-formed.
  • If Z is the concatenation of X and Y, then the value of Z is the composition of the values of X and Y.
Sadly, the official website is no longer hosted by La Trobe University however there is a reasonably complete mirror hosted by Kevin Albrecht and the Wikipedia page is helpful.

Hello World in Joy?

"Hello, world!\n" putchars .

Quicksort in Joy?

DEFINE qsort ==
  [small]            # termination condition: 0 or 1 element
  []                 # do nothing
  [uncons [>] split] # pivot and two lists
  [enconcat]         # insert the pivot after the recursion
  binrec.            # recursion on the two lists (full-stop ends the define)

Who invented Joy?

Manfred von Thun was the inventor of the Joy programming language.

According to the LaTrobe University Alumni news:

"Alumni and staff will be saddened to hear of the death of Manfred von Thun on 23 October after a long illness. Manfred was a member of the philosophy department from early 1972 until his retirement in 2003, but remained an honorary associate until 2009. Manfred specialized in logic, philosophy of science, philosophy of mind, computer programming and cybernetics. He was also renowned for developing the computer programming language, Joy. He will be sadly missed."


Joy’s inventor, Manfred von Thun 


Sunday, 8 December 2019

Enable CGI Apache2 (Debian et al)

C++ Server Side Web Development

CGI, the Common Gateway Interface is a simple way to write web applications. It is by no means the fastest and some may say that:

"If you're planning to write your web application in C++, it would be total waste to then interface it as CGI.

My suggestion would be to build it asynchronous using ASIO (Asynchronous I/O). With that you can build blazing fast web service (combine with nginx as a reverse-proxy and statics server for best effects); Combine that with template library like Wt and you're ready to serve tens of thousands request per second from a single server.

Whether this is practical alternative to dynamic language web framework is another issue." vartec 2013 

However, it is a simple way of demonstrating server side web development with a number of programming languages, including C++.

Install Apache2

To support websites built with C++ using the CGI requires webserver software capable of (which is all of them) and configured to enable (not all of them) execute code in a cgi directory.

Monday, 1 January 2018

C++ Mellor-Crummey & Scott (MCS) Lock - Milestones In Computer Science


I have been reading Herlihy, Maurice; Shavit, Nir. The Art of Multiprocessor Programming, Revised Reprint. Elsevier Science. (Kindle Edition) and converting the Java lock code into C++ here is my favourite so far: 

The Mellor-Crummey & Scott Spin Lock

The Mellor-Crummey & Scott (MCS) Lock, due to John Mellor-Crummey and Michael Scott improves upon their ticket lock by expanding a spinlock into a per-thread structure, an MCS lock is able to eliminate much of the cache-line bouncing experienced by simpler locks, especially in the contended case. 

The MCS Lock use an explicit linked list of synchronization variables, into which threads' synchronization variables are enqueued by order of arrival and avoids thread starvation by guaranteeing that an enqueued thread will, eventually, get access.

The MCS Lock is, therefore, fair and scalable and is the primary example of linked list queue lock family of locking strategies.

Its creators were awarded the 2006 Edsger W. Dijkstra Prize in Distributed Computing for their 1991 paper, "Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors."

Tuesday, 9 May 2017

Tic-Tac-Toe Bitboards


CPE1704TKS

Board Games are, generally speaking, a collection of position based states and whilst it might seem intuitive for games like draughts, othello, chess, etc to have their positional states encoded in arrays and matrices of integers or floats it isn't efficient and it certainly isn't easy to reason about those states. So, quite early on (1950s and 1960s) it was discovered, and rediscovered, that it is more efficient to represent game states as 1 dimensional collections of bits and, more importantly, much easier and faster to reason about those states using boolean operators.

Such 1D bit arrays are termed bitboards and reach their zenith of complexity and utility in the game of Chess.

But it's not just Chess that can benefit from bitboards so can the humble game of Tic-Tac-Toe (a.k.a. Noughts & Crosses if you're Blighty based).