What is virtual machine? how to and why to use them?

A virtual machine (VM) is an operating system (OS) or application environment that is installed on software, which imitates dedicated hardware. The end user has the same experience on a virtual machine as they would have on dedicated hardware.

  • download an app called virtualBox.org
  • have a computing ready
  • have the OS downloaded, ex: linux.iso

For night build

For try out new system without sacrifies your own OS

For gaming

How to write the bash script?

first line: "#!/bin/bash"

the file name is .sh

These rules are called file permissions or file modes. The command name chmod stands for "change mode", and it is used to define the way a file can be accessed.

$ chmod +x hello_world.sh

how to execute?
./hello_world.sh

Difference between Linux and Windows?

Short Answer: Difference is in ecosystems they represent and client base that each refer.

I am pretty sure you have information about Windows and may be about its development world, that is mostly windows operating system with .NET framework and iconic products like MS office, outlook, etc. This world mainly tight to licencing.

While Linux (Unix )world is complete opposite to licencing with many open-source products like Open Office, Java, etc. Thus, Unix world developers always religiously oppose the Microsoft world (windows) as a corporate greed, where each product should be paid first.

However, there were drastic changes in Microsoft software development approach in terms of going open-source. Thanks to GitHub and similar software project hosting websites and community of developers that use and contribute to it. For example, ASP.NET MVC is an open source framework, NuGet packages are free as well.

What is thread?

A thread is a lightweight subprocess.It is a separate path of execution.It is called separate path of execution because each thread runs in a separate stack frame.

What is multithreading?

Multithreading is a process of executing multiple threads simultaneously. Its main advantage is:

Threads share the same address space.

Thread is lightweight.

Cost of communication between process is low.

What is the difference between a process and a thread?

Threads are used for small tasks, whereas processes are used for more 'heavyweight' tasks – basically the execution of applications. Another difference between a thread and a process is that threads within the same process share the same address space, whereas different processes do not

Hardware and Software

  • A computer is a machine designed to perform operations specified with a set of instructions called a program. !
  • Hardware refers to the computer equipment. " keyboard, mouse, terminal, hard disk, printer, CPU !
  • Software refers to the programs that describe the steps we want the computer to perform. !
  • The software that manages the hardware and shares the hardware between different application programs is called the operating system.

How do we translate to machine readable form?

"A computer program called a compiler is used to translate the text file (called a source file) containing the assembler code into machine readable code(binary code)

In many systems an additional hardware component called a PIC (Programmable interrupt controller) is used.

  • When a PIC is used all interrupts are sent to the PIC and the PIC queues and manages the interrupts 􏰁
  • The PIC will usually send only one interrupt at a time to the CPU (unless preempted by a more critical interrupt).

We can do IO
􏰁

  • without interrupts(BusyWaiting or Programmed IO) 􏰁
  • with interrupts(interrupt driven IO)

Multiprogramming
􏰀􏰀

  • Partition memory into pieces (often of different sizes) 􏰀
  • Load one job into each partition (choose partition according to needs of job) 􏰀
  • Have multiple jobs executing simultaneously, one in each partition 􏰀
  • When one job is I/O bound another can be using the CPU

Resource ownership: its owned by process and shared by threads

(Round Robin)

轮转法(Round Robin)是让每个进程在就绪队列中的等待时间与享受服务的时间成正比例。

A race condition occurs when two or more threads can access shared data and they try to change it at the same time. Because the thread scheduling algorithm can swap between threads at any time, you don't know the order in which the threads will attempt to access the shared data. Therefore, the result of the change in data is dependent on the thread scheduling algorithm, i.e. both threads are "racing" to access/change the data.

Problems often occur when one thread does a "check-then-act" (e.g. "check" if the value is X, then "act" to do something that depends on the value being X) and another thread does something to the value in between the "check" and the "act". E.g:

if (x == 5) // The "Check"

{

y = x * 2; // The "Act"

// If another thread changed x in between "if (x == 5)" and "y = x * 2" above,

// y will not be equal to 10.

}

The point being, y could be 10, or it could be anything, depending on whether another thread changed x in between the check and act. You have no real way of knowing.

In order to prevent race conditions from occurring, you would typically put a lock around the shared data to ensure only one thread can access the data at a time. This would mean something like this:

// Obtain lock for x

if (x == 5)

{

y = x * 2; // Now, nothing can change x until the lock is released.

          // Therefore y = 10

}

// release lock for x

Virtual Memory: indirection 间接的

before VM: program address = RAM address

results matching ""

    No results matching ""