Having done a fair few academic computer science courses and various coding jobs in a past-life I found that it was often thinking about the smallest code snippets carefully that you pick-up the raw building blocks for good, safe and efficient code. I haven’t written much code recently so have been brushing up my basics.
Compilers are now so good and computers so powerful that in practice you can write pretty terrible code and still make a perfectly performant and functional application.
One famous code problem is to swap two numbers without using an additional temporary variable. So you use only the memory already storing the numbers without requiring extra for the temporary variable. Consider….
Method 1: Using a temporary variable
int a = 6;
int b = 5;
temp = a;
a = b;
b = temp;
Method 2: Avoiding a temporary variable
int a = 6;
int b = 5;
a = a + b;
b = a – b;
a = a – b;
OK now let’s think about this harder, which method is better?:
- Method 2 seems clever and no unnecessary memory used
- It’s far less readable
- If you really are just swapping two integers the extra memory for a single integer is negligible
- the sum (a+b) can larger than the addressable space of an integer so overflow could occur, i.e. (a+b) could wrap around and the algorithm break!
- If using real or another data type you could pick up machine level errors
- I suspect many modern compilers would take care of this for you
- With method 1; a is safely stored in temp should something go wrong
- Both methods use the same number of copies but the amount of checking required to ensure no overflow occurs on (a+b) and similar really is more trouble than it’s worth and would make the code look messy
So when would you avoid a temporary variable:
- When you are certain your data is going to be well below half the capacity of the data type (e.g. int) – more relevant if looking at facetted data in real format; i.e. scenarios where you can safely avoid extra checks and code
- When you don’t care about machine level noise
- When it isn’t just two pieces of data but a vast array of data perhaps representing a frame buffer or screen
Of course, we can now go on to ponder how this code could be made fail safe…. But it’s amazing how three lines of code make you think a bit harder…. And another discussion is using pointers …
I’d be interested to hear whether people actually use Method 2 (other than those using EDSAC2) and how much can be relied on to be taken away by compilers… and whether people still think hard about such things…
Last year I wrote a blog on how to find out which Linux distributions are supported by VMware/Citrix, at the time I struggled to find some of the Citrix info as there wasn’t a master list in their documentation. With the recent 7.12 XenDesktop release though this changed and there’s now a nice clear list in the System Requirement Documentation (at the time of writing for 7.12), this reads:
- SUSE Linux Enterprise:
- Desktop 12 Service Pack 1
- Server 11 Service Pack 4
- Server 12 Service Pack 1
- Red Hat Enterprise Linux
- Workstation 6.8
- Workstation 7.2
- Server 6.8
- Server 7.2
- CentOS Linux
- Ubuntu Linux
- Ubuntu Desktop 16.04
- Ubuntu Server 16.04
It’s great to see the addition in 7.12 of support for Citrix users for the Ubuntu OS. It is important you use a supported _version_ to ensure support. There’s a really good overview of this addition and other details of the latest Linux VDA from the Citrix Product Manager for the product, Vipin Borkar, on the Citrix blog – worth a read, here.
VMware Linux VDA Support
For VMware there is similar documentation linked to from their Linux VDA home page in the “Horizon 7 for Linux FAQ”.
- Which flavors of Linux are supported in the first release of Horizon 7 for Linux?
- Ubuntu 12.04 and 14.04, Red Hat Enterprise Linux (RHEL) 6.6 and 7.1, CentOS 6.6, and NeoKylin 6 Update 1 (Chinese), SUSE Linux Enterprise Desktop 11 SP3 are supported with Horizon 7 for Linux.
NVIDIA GRID Support
NVIDIA GRID vGPU technologies also support some Linux OS versions and distributions. These are a subset of those supported by VMware and Citrix so you need to also check that as well as using a supported OS for the Linux VDA in use that you also use a version supported by the vGPU technologies. The OS versions and genres supported for each hypervisor are listed in release notes for the driver for each hypervisor, these are available in the driver download but have been added to NVIDIA’s knowledge base for certain releases, e.g.
If you are mixing vendors for VDI and hypervisor, e.g. Citrix XenDesktop on VMware ESXi you will also want to double check the hypervisor and Linux VDA support matrices overlap.
XenServer Support for Linux Guest OSs
This is documented in the “Citrix XenServer® Virtual Machine User’s Guide” for the relevant version of XenServer e.g. for 7.0, here: http://docs.citrix.com/content/dam/docs/en-us/xenserver/xenserver-7-0/downloads/xenserver-7-0-vm-users-guide.pdf
ESXi/vSphere Support for Linux Guest OSs
Supported Linux OSs are listed in the “VMware Compatibility Guide”: https://www.vmware.com/resources/compatibility/search.php?deviceCategory=software