Category Archives: Operating Systems

Topic 1 – Operating Systems

Why do I need to learn about operating systems?

Because you will develop your software using an operating system or for an operating system.

How many operating systems should I know?

As many as possible. We recommend that you learn how to work with Windows first. Then you learn about basic concepts of an operating system.

How do I learn about operating systems under a user’s view?

Please read this Andy Rathbone (2015). Windows 10 For Dummies. Wiley book.

How about other operating systems such as macOS, Linux or Unix?

If you have a Mac then you can read this Pogue David (2019). macOS Mojave: The Missing Manual. O'Reilly Media book.

If you have a PC with Ubuntu Linux or Unix then you can read this Mark G. Sobell (2015). A Practical Guide to Ubuntu Linux. Prentice Hall book.
After reading these books please read this Abraham Silberschatz et al. (2013). Operating System Concepts. Wiley book to grasp basic concepts of an operating system.

Once you finish reading these books please click Topic 2 - Introduction to Programming to continue.

How to Hide Your IP Location using VPN in Windows 10

Motivation:

You have VPN credentials and want to hide your IP location for a specific purpose.

Solution:

  • Setup a VPN connection using your VPN credentials.
  • Type and click View network connections in Search box to open the Network Connections window.
  • Right-click the VPN connection and select Properties in the menu.
  • Select the Networking tab.
  • Click the Internet Protocol Version 4 (TCP/IPv4) row, then click the Properties button.
  • Click the Advanced… button.
  • Select Use default gateway on remote network option.

How to Fix “The parameter is incorrect” Issue When Disabling the Sync Host OneSyncSvc Service

Problem:

The Sync Host OneSyncSvc service was not started correctly and caused error in the Server Manager.

You wanted to disable this service. However you got the “The parameter is incorrect” error message when disabling it.

Solution:
  1. Click on the Search icon, type regedit, press Enter.
  2. Locate the key below
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\OneSyncSvc

3.  Change the Start value from 2 to 4 (Disabled).

4. Restart the server.

 

How to Fix the “We can’t sign into your account” Issue in Windows

Problem:

You remotely connect o a computer using a Windows Domain account and get the error message below.

We can't sign into your account
Solution:
  1. Login the computer as a Local Administrator.
  2. Open C:\Users and delete the folder of the Windows Domain account.
  3. Click Search icon, enter regedit, and press Enter.
  4. Navigate to the path below.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList

4. Look for the Profile of the Windows Domain account by reviewing the ProfileImagePath value.

5. Delete the Profile key of the Windows Domain account.

6. Restart the machine.

How to Manually Install PHP 7.4 for Windows Server 2019

Motivation:

To understand how PHP works with IIS in order to be able to update PHP to any version to address compatibility or security issues.

Using a tool to install PHP for IIS, for example Microsoft Web Platform Installer 5.0 https://www.microsoft.com/web/downloads/platform.aspx, restricts us from using only versions supported by the tool.

Solution:

  • Install CGI for IIS.
  • Download VC15 x86 Non Thread Safe package here or under PHP 7.4 section from http://windows.php.net/download/
  • Extract the ZIP file to the C:\Program Files (x86)\php-7.4.9-nts-Win32-vc15-x86 folder.
  • Rename the php-.ini-development file to php.ini.
  • Open the php.ini file and add the following line at the end of the file.
extension=php_wincache.dll
  • Uncomment the following lines
fastcgi.impersonate = 1;

cgi.fix_pathinfo=1;
cgi.force_redirect = 1 (and change the value to 0, i.e. cgi.force_redirect = 0)

extension_dir = "C:\Program Files (x86)\php-7.4.9-nts-Win32-vc15-x86\ext"

extension=php_curl.dll
extension=php_fileinfo.dll
extension=php_mbstring.dll
extension=php_exif.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
extension=php_openssl.dll

error_log = "C:\Program Files (x86)\php-7.4.9-nts-Win32-vc15-x86\php_errors.log"

error_log = syslog
  • A sample php.ini file can be download here.
  • Add C:\Program Files (x86)\php-7.4.9-nts-Win32-vc15-x86 to System Path.
  • Download x86 package of WinCache 2.0 for PHP 7.4 here or from https://sourceforge.net/projects/wincache/.
  • Extract and copy the php_wincache.dll file to C:\Program Files (x86)\php-7.4.9-nts-Win32-vc15-x86\ext
    folder.
  • Open IIS, click on Server name, double click on Handler Mappings, click on Add Module Mapping, and enter below information
Request path = *.php
Module = FastCgiModule
Executable = "C:\Program Files (x86)\php-7.4.9-nts-Win32-vc15-x86\php-cgi.exe"
Name = PHP 7.4
Request Restrictions = File or folder

Open a Command Prompt, execute below command and ensure that NO WARNINGS APPEAR.

php -version
  • Create phpinfo.php file with below content in the website folder and test the result.
<?php
phpinfo();
?>

 

How to Run Docker on a Windows 10 Hyper-V Virtual Machine

Motivation:

You want to have an environment with Docker for development and testing  without interfering your stable machine.

Procedure:

1. Download this PowerShell script. The main interesting command in this script is the command below that enables Nested Virtualization for a virtual machine.

Set-VMProcessor -VMName $vmName -ExposeVirtualizationExtensions $true

2. Open PowerShell as Administrator and execute 2 commands below.

Set-ExecutionPolicy -ExecutionPolicy "Unrestricted"
.\Enable-NestedVm.ps1 "Windows 10 Dev"

"Windows 10 Dev" is the virtual machine name without quotes.

3. Install Docker. Restart the virtual machine.

4. Install any additional software if needed, restart the virtual machine again.

5. Open a Command Prompt and test Docker installation.

docker pull hello-world && docker run hello-world

Rerun the command if you get an issue in the first run.

How to Enable Processor Resource Controls in Hyper-V

Context:

You got a warning message below when configuring Number of virtual processors in Hyper-V.

Hyper-V is not configured to enable processor resource controls.
Problem:

How do you enable processor resource controls in Hyper-V?

Solution:

1. What is the difference between core and logical processor?

  • A socket is a slot contains one or more mechanical components providing mechanical and electrical connections between a microprocessor and a printed circuit board (PCB). This allows for placing and replacing the central processing unit (CPU) without soldering.
  • A core is a physical processor unit (hardware component) inside your processor.
  • Logical processor or logical core is the processor as seen by the operating system. Logical processor does not exist physically.
Logical Processor = (# of Core) * (# of Thread in each Core) = 4 * 2 = 8

Example:

2. What is SMT?

Simultaneous multithreading, or SMT, is a technique utilized in modern processor designs that allows the processor’s resources to be shared by separate, independent execution threads.

Processors supporting SMT are available from both Intel and AMD. Intel refers to their SMT offerings as Intel Hyper Threading Technology, or Intel HT.

3. How does Hyper-V virtualize processors?

  • Hyper-V creates and manages virtual machine partitions, across which compute resources are allocated and shared, under control of the hypervisor. Partitions provide strong isolation boundaries between all guest virtual machines, and between guest VMs and the root partition.
  • The root partition is itself a virtual machine partition, although it has unique properties and much greater privileges than guest virtual machines. The root partition provides the management services that control all guest virtual machines, provides virtual device support for guests, and manages all device I/O for guest virtual machines. Microsoft strongly recommends not running any application workloads in the root partition.
  • Each virtual processor (VP) of the root partition is mapped 1:1 to an underlying logical processor (LP). A host VP always runs on the same underlying LP – there is no migration of the root partition’s VPs.
  • By default, the LPs on which host VPs run can also run guest VPs.
  • A guest VP may be scheduled by the hypervisor to run on any available logical processor. While the hypervisor scheduler takes care to consider temporal cache locality, NUMA topology, and many other factors when scheduling a guest VP, ultimately the VP could be scheduled on any host LP.

4. What are Hyper-V hypervisor scheduler types?

Starting with Windows Server 2016, the Hyper-V hypervisor supports several modes of scheduler logic, which determine how the hypervisor schedules virtual processors on the underlying logical processors. These scheduler types are:

  • The classic scheduler provides a fair share, preemptive round- robin scheduling model for guest virtual processors.
  • The core scheduler offers a strong security boundary for guest workload isolation, and reduced performance variability for workloads inside of VMs that are running on an SMT-enabled virtualization host.
  • The root scheduler cedes control of work scheduling to the root partition. The NT scheduler in the root partition’s OS instance manages all aspects of scheduling work to system LPs.

5. Determine your current Hyper-V Hypervisor Scheduler Type

Execute the command below.

Get-WinEvent -FilterHashTable @{ProviderName="Microsoft-Windows-Hyper-V-Hypervisor"; ID=2} -MaxEvents 1

  • 1 = Classic scheduler, SMT disabled
  • 2 = Classic scheduler
  • 3 = Core scheduler
  • 4 = Root scheduler

6. Enable processor resource controls in Hyper-V by setting Scheduler Type to Core or Classic.

  • Open a Command Prompt as Administrator and execute the command below.
C:\Windows\System32\bcdedit.exe /set hypervisorschedulertype Core

  • Restart the computer.
Sources:

https://en.wikipedia.org/wiki/CPU_socket

https://www.quora.com/What-is-the-difference-between-core-and-logical-processor

https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/manage/manage-hyper-v-scheduler-types

 

How to Trim MP4 Files Without Re-Encoding

Motivation:

You have MP4 files with unwanted portions. You want to trim these portions.

Solution:

  1. Download XMedia Recode.
  2. Under the Format tab set
    Profile = Custom
    Format = MP4
    File Extension = mp4
  3. Click the Video tab and select Copy Mode.
  4. Click the Audio tab and select Copy Mode.
  5. Click the Filters/Preview tab and set Start Time and to (End Time).
  6. Click Add to queue button on the tool bar.
  7. Click Encode on the tool bar.

 

How to Put Your Books into Kindle or Apple Books

Motivation:

You have a book with .epub or .mobi format in your MacBook or PC.
You want to put it into your iPhone or iPAD so that you can read it on the go.

Solution 1:

1. Put the books into iCloud Drive.
2. Install Kindle or Apple Books on your iPhone or iPAD.
3. Login your Kindle account.
4. Open the Files app to go to iCloud Drive.
5. Open the book.
6. Tap the Share icon in the lower left hand corner.
7. Select Kindle or Open in iBooks.

Solution 2:

1. Install Kindle or Apple Books on your iPhone or iPAD.
2. Log in your Amazon account.
3. Point mouse to Account & Lists, then click Content and Devices link.
4. Click Preferences tab, then click on Personal Document Settings  header.
5. Copy or create your Kindle email in Send-to-Kindle E-Mail Settings section.
6. Add your personal email to Approved Personal Document E-mail List.
7. Attach your book to an email, then send the email from your personal email (in the 6th step) to your Kindle email (in the 5th step).
8. Log in your personal email’s Inbox and click on Verify Request link.

How to Install a Fresh Windows 10 Booted from UEFI Secure Boot using a Bootable USB

Problem:

Most of Windows machines are delivered with a limited Windows version and unnecessary preinstalled software.

You want to format the hard drive and install a fresh Windows that can be booted from UEFI secure boot to improve machine performance and stability.

You have a 8Gb USB stick and an ISO file of Windows 10, version 2004.

Solution:

Step 1: Backup your machine and create an USB recovery by entering “Create a recovery drive” text to the search box on the task bar and follow the instructions.

Step 2: Create a bootable USB with Windows installation files.

Right click Windows logo, click Command Prompt (Admin).
Enter diskpart.exe, press Enter.
DISKPART> list disk
DISKPART> select disk 1 -- the USB disk should be selected, the number may be different in your machine.
DISKPART> clean
DISKPART> create partition primary size=1024
DISKPART> select partition 1
DISKPART> active
DISKPART> format quick fs=fat32
DISKPART> assign
DISKPART> create partition primary
DISKPART> select partition 2
DISKPART> format quick fs=ntfs
DISKPART> assign
DISKPART> exit
Double click on the ISO file of Windows 10, version 2004 to create a virtual drive.
xcopy f:\sources\boot.wim d:\sources\ /s /e 

where
f: the virtual drive and 
d: the USB fat32 partition.
We copy only the f:\sources\boot.wim file to d:\sources\.
robocopy f:\ d:\ /IS /S /XD sources 

where 
f: the virtual drive and 
d: the USB fat32 partition.
We copy everything from f:\ to d:\ except the sources folder.
xcopy f:* e:\ /s /e 

where 
f: the virtual drive and 
e: the USB ntfs partition.

Step 3: Install Windows.

  1. Plug the USB to a machine.
  2. For a Dell laptop, power on the machine, press F12 until a one-time boot up menu appears. Select the option to boot the machine from the USB. (You may need to access BIOS to enable Boot from an USB).
  3. For a Sony VAIO laptop, power off the machine, then press the Assist button to enter VAIOCare. Select the option to boot the machine from the USB. (You may need to access BIOS to enable Boot from an USB).
  4. For a ThinkPad laptop, go to Settings > Update & Security > Recovery, click the Restart now button under the Advanced setup section and follow the instructions to boot the machine from an USB.
  5. Follow the instructions to install Windows (set Windows partition size to 716916Mb for DellPrecision if you want to have 700Gb C drive, or 262789Mb for DellXPS if you want to have a 255Gb C drive, or 819316Mb for DellXPS if you want to have a 800Gb C drive).
  6. You can delete all the partitions, including MRP (Microsoft Reserved Partition – this is just a reserved partition for Windows later use if needed), ESP (EFI System Partition – this is where UEFI firmware files are stored to boot Windows), WINRETOOLS (Windows Recovery Environment (WinRE) Tools – this is where files for repairing or recovering Windows are stored), and PBR image (this is where original the manufacture Windows installation file  are stored) because you already created an USB recovery in the Step 1.

Step 4: Configure Windows for Developer’s needs.

  1. Change Computer Name, turn off System Restore, enable Remote Desktop.
  2. Add Wireless LAN Service feature for Windows Server 2019.
  3. Install Dell Wireless 1820A 1830 WiFi Driver
  4. Change Time Zone.
  5. Turn on Network discovery and file sharing by clicking on Network icon on the left side of Explorer, turn off BitLocker (manage-bde -status, manage-bde -off C:).
  6. Activate Windows.
  7. Configure Auto Logon (netplwiz), disable Hibernation (powercfg.exe /h off), configure Power options (Hard disk >> Turn of hard disk after: 0, Wireless Adapter Settings >> Power Saving Mode: Maximum Performance, Sleep >> Sleep after: 0).
  8. Install Dell Command Update and use it to install necessary drivers.
  9. Install Chipset Device, Graphics, Audio, Ethernet, Bluetooth, Memory Card Reader, Dynamic Platform and Thermal Framework driver for Windows Server 2019.
  10. Turn the following Windows features on: .NET 3.5, ASP.NET 4.8, Internet Information Services, Telnet Client.
  11. Install Hyper-V, create an external Virtual Switch for Internet access, set Scheduler Type to Core.
  12. Apply Windows updates to the machine.
  13. Configure secure protocols using IIS Crypto GUI (Select Best Practices, disable TLS 1.0, TLS 1.1, MD5, SHA).
  14. Install Total Commander, Remote Desktop Connection Manager, PuTTY 0.7.3, WinSCP 5.17, Zoom.
  15. Install Firefox, MPC-HC.1.7.13.
  16. Install MS Office 2007 SP3 (Display >> Scale and layout: 125% for DellPrecision, 175% for DellXPS), MS Project 2016, MS Visio 2016, MS SQL Server 2008 R2, Visual Studio 2015, Adobe Acrobat Pro DC v15.8, Adobe Photoshop CC 2015, TortoiseSVN 1.13.1
  17. Install Python 3.6.8, TensorFlow, Keras
  18. Create VPN Connection.

Go to Control Panel >> Network and Sharing Center >> Change adapter settings >> Right click >> VPN Connection’s Properties >> Select Networking tab:
1. Disable Internet Protocol Version 6 (TCP/IPv6).
2. Select Internet Protocol Version 4 (TCP/IPv4) >> Properties >> Advanced… >> select IP Settings tab: Uncheck Use default gateway on remote network option.

 

How to fix “An internal error has occurred” issue of Remote Desktop Connection

Problem:

You get “An internal error has occurred” error message when trying to connect to a remote machine using Remote Desktop Connection.

Solution:

1. Type Local Security Policy to the Windows Search box.

2. Click Open link.

3. Expand Local Policies > Security Options on the left panel.

4.  Double click on System cryptography: Use FIPS compliant algorithms for encryption, hashing, and signing row on the right panel.

5. Select Enabled, click Apply and click OK.