piątek, 28 sierpnia 2015

upgradeable RW-locks - no, no

Never to be forgotten - upgradeable RW-locks always lead to deadlock.
I.e. when reader upgrades to writer without first leaving read lock, then other tread doing same lead to deadlock - no one moves back - deadlock.
Therefore:
- do not think on upgradeable RW-locks,
- if do so, then try-upgrade() function might be good approach, or
- deadlock detection, or
- 3rd user type - beside reader and writer - upgreadeableReader (like EnterUpgradeableReadLock from .NET). There can be only one upgreadeableReader (mutually exclusive). Normal readers cannot upgrade, therefore it is certain that only one user-reader will try to upgrade.

Redirect tcp to console (file) with awk

Sometimes useful, esp. when redirecting local tcp process output to console (file):

BEGIN {
NetService = "/inet/tcp/0/localhost/finger"
print "name" |& NetService
while ((NetService |& getline) > 0)
print $0
close(NetService)
}

More info @http://www.gnu.org/software/gawk/manual/gawkinet/gawkinet.html#Making-Connections

QNX specific commands

List of interesting (subjective) QNX-specific commands
  • on - usually used for 2 reasons: start new process with specified priority and/or start new process on specific node (it makes possible to start process on different processor/system running QNX - working qnet is required - see Asymmetric multiprocessing (AMP))
  • pidin - process list, frequently more useful than ps, top (e.g. options "-f A", "-f n","threads", "memory", "fds")
  • coreinfo - allows for preliminary corefiles analysis directly on target without using gdb (note that in QNX coredumps are produced by dumper)
  • use - info about specific command (e.g. "use devf-generic", "use -i devf-generic" - for build version)
  • sendnto e.g. "sendnto -d /dev/ttyUSB1 qnx-ifs" (together with "cat /dev/ttyUSB1" and "echo 's' >/dev/ttyUSB1")