Tuesday, June 29, 2021

CST 334 Operating Systems Module 1 : Introduction to Operating Systems

1.0 Week Preview Agenda

After completing this module, you should be able to:

  • Describe the basic concept of an Operating System
  • Convert between number bases (binary, decimal hexadecimal)
  • Write a basic bash shell program
  • Write a C program starting from a template
  • Use a makefile to compile a C program
  • Test C code using bash scripts

1.1 Answer the agenda 

1.1.1 Describe the basic concept of an Operating System

Book: The operating system (OS) is a body of software that makes it easier to run a program by by managing the computer's memory and processes as well as all of its software and hardware which it does in many ways.

1. Virtualization: First, it uses a technique called virtualization in which the OS takes a physical resource such as memory and transforms it into a more easy to use and more powerful virtual form of itself (we sometimes call the OS a virtual machine). 

  • CPU Virtualization:  The OS in conjunction with the hardware is able to turn the singe CPU in an infinite number of virtual CPUs which allows many programs to seemingly run at once. 
  • Memory Virtualization: The OS creates a virtual address space which the OS then maps onto the physical memory of the machine. A memory reference within one running program doesn't affect the address space of another program because in reality, it has a physical address of its own.

2. APIs: Second, the OS also provides interfaces called APIs in order to allow users to tell the OS what to do/make use of the virtual machines such as allocating memory, running a program, or accessing a file. The OS exports a few hundred system calls (ways for program to interact with OS) available to applications. 

3. Managing Resources: Third, the OS acts as a resource manager because virtualization allows lots of programs to run (thus sharing CPU), access their own instructions and data (thus sharing memory) and access devices (thus sharing disks). The OS manages the hardware resources in order to efficiently run a program.

Lecture: An operating system refers to the central software that manages and allocates computer resources such as the CPU, RAM, and other devices. It is the middleware between user programs and system hardware. The operating systems have 2 key roles; 1). provides convenience to user by providing a level of abstraction and 2). makes for efficient use of the hardware such as decreasing the amount of wait time between I/O. 

1.1.2 Convert between number bases (binary, decimal, hexadecimal)

Converting between decimal to binary is simple. In binary, we are working with base 2. All you need to do is keep dividing by 2 until you have your quotient equal to zero. In order to get the binary, write the remainder from bottom to top. 

Converting between decimal to hexadecimal is also quite simple. See figure below. 






1.1.3 Write a basic bash shell program

Shell scripts are files that contain a series of commands which the shell reads and carries out the commands as though they have been entered on the command line. The ability of the shell to act as a command line interface and a scripting language interpreter makes it unique. In order to write a script, you first need a text editor such as vim or Emacs. After writing the script, you need to give the shell permission to execute it. Finally, you need to put it somewhere that the shell can find it. When writing a shell script, you need to have your first line, the shebang, to indicate to the system what program is going to be used to interpret the script such as bash. Setting the permission to execute the script is simple. You just need to use the chmod command in order to give permission to read, write, and execute. Finally, you can run the script by providing the path.

One way shell scripts can be useful is task automation for everyday tasks. If you have a task that you do everyday like uploading files to a server or send out emails at specific times, you can write and store commands in a shell script and run the script. A second way that shell scripts can be useful is that it is portable. This means that you can use any machine that has the shell installed such as bash.

This week we learned how to write simple bash scripts in the lab. I'm having a hard time debugging it but i I think I can get it working. This is what i have so far. I will update with the working script later. 


 

These topics were posted on the weekly learning bulletin but were not taught:

Write a C program starting from a template

Use a makefile to compile a C program

Test C code using bash scripts

No comments:

Post a Comment

CST 499 Capstone - Week 8 Learning Journal Final Entry

This is the very last entry of the journal of your CS Online learning!  Keeping regular journals is a great way for us to grow, both profe...