Posts

Operating Systems in a Nutshell !

Operating systems are event driven collection of programs that manages integrate hardware and software services and makes them available to users, hardware, and other operating systems. The main goal for an Operating system is to make it easier for users and I/O devices. The major services of the operating system are:

User Interface and Command Execution Services

The main purpose of this service is to be an intermediate between the user and the computer. The two main interfaces are the Graphical User Interface GUI and the Command Line Interface CMI. As their names suggest with the GUI everything is primarily displayed as images and somewhat “dumb-ed” down for users. The CMI mechanism provides the user with a usually black screen, and the user can type in commands he wants to be executed.

The command execution service can be subdivided into two categories, resident and nonresident commands. The resident commands are those commands the reside in memory in order to be accessed immediately. The nonresident commands, as you might expect, do not remain on memory and is loaded into memory as necessary.

File management

The OS also serves file management system. Because files are not always stored contiguously on the disk a file management system is needed in order to be able to keep track where files are stored on the disk. The file management system also provides tools, in which a user can copy, move or load a file. It also takes care of providing I/O devices with the files needed, even though the I/O device or the user doesn’t know the file structure of the device being accessed.  More advanced file management systems provide users with back up features and recovery mechanisms which are useful if “things go wrong.”

Input/Output Services

Some of the I/O services include the implementations of interrupts (described in a previous post). The I/O drivers also assure access to critical devices.  These drivers are usually stored in the systems BIOS. The Basic Input Output System is responsible for initializing major I/O devices when first starting up a computer. Some of these I/O peripherals include the keyboard, mouse, graphics card, hard disk…etc

Process Control Management

A process is simply a program in execution. The Operating system, which also consists of processes, manage these processes giving them the “right of execution.” Also it keeps track of what resources each process needs and what resources have been released from a process to make it available for other processes. Some programs break down processes even further down into what is called threads.

Memory Management

Memory management is a very important service of an operating system. It allocates memory for process to be able to execute. It also keeps track of memory in use, and may provide a process with more memory as needed. It also clears up memory when a process is done with execution. The concept of virtual memory becomes very important here, and the reason why the user feels the computer is actually multi-tasking, doing more than one thing at a time. I will elaborate about this concept in a later post.

Scheduling and Dispatch

In order for no process to starve the operating system is in charge of scheduling which process is next on the list to be executed, this is called high level scheduling. It is also responsible of dispatching the processes, in which is the actual selection of the process in which will transmitted for execution.

This task is a very hard task in order to have an efficient and smooth running system. There are many strategies used. The first one is the a program uses the CPU and once it needs to use an I/O device the second program is executed and so on. A more effective method is by using a technique called time-slicing. What happens within this technique an OS dispatcher program throws an clock interrupt and give another process the “right of execution.”( I like using the word throw because it remind me with exceptions “thrown” in JAVA)

This service is also responsible for what is called context switching. It is responsible for the preservation of the context of a process and reloading it later on. The context of a process are: the process state, program counter, register values, and other parameters representing the state of the program.

Secondary Storage Management

The secondary storage management makes use of completing I/O tasks in an efficient manner; it uses a combination of both software and hardware to make it possible. It uses different algorithms   in order to facilitate the disk space in such a manner that would be able to maximize the use of the disk.

Network and Communications Support Services

The operating system provides users with an array of network and communication services. Some include the top layers of the TCP/IP suite, which was described in a previous post. Other applications includes the control of VoIP and other network applications such as file sharing.

System Administrative Support And Security.

The Operating System allows users to change different settings on the computer in an easy manner. This of course includes administrating different users on a certain computer, managing networks and others. Security is also an important part of the operating system. Some of these services includes protecting user files from other users on the computer, or preventing users from accessing system files on the computer.

DNS

In a previous post I talked about the different layers of the TCP/IP. At the application layer I mentioned user friendly addresses, such as URLs as www.bentley.edu . the question that arises is how does the computer know where that URL references to. The Domain name System protocol (DNS) is responsible for translating this URL/domain name into an IP address. The question is how does it do so, especially when there are an infinite number of addresses? When you enter any URL in your web browser and hit the enter key the following happens to return the IP address used to request the page. Keep in mind that this protocol usually uses UDP because the data requested is relatively small.

1)      A query is generated from your internet explorer sends it to a local domain name server.

2)      The query runs within the local DNS table and checks if the IP address is within this database. If it is available it is sent back to the DNS client application, which sends it back to the HTTP client (internet browser)

3)      If the local DNS table doesn’t contain  that URL the local DNS server sends the root server. The root server returns an IP address of the closest top-level servers.

4)      The query runs through the top level server and looks up the top level part of the URL; the .com or .edu.

5)      Then another query is run form the top level domain, querying to an authoritative DNS server, returning the IP of the local address. the Bentley in the Bentley.edu

6)      The IP address is then returned to the DBNS client and then returned to the HTTP client (web browser)

Ethernet Vs. Wireless

In local area networks three type of networks are usually used, hub-based Ethernet, the switched Ethernet and/or wireless Ethernet. The hub based Ethernet uses a central device called a hub, in which all nodes on the network are connected to this device. The hub-based Ethernet has a physical topology of a start. However once you know how it works you would conclude it is a logical bus network. What the hub does is when a node sends out a message it broadcasts the message to all the nodes on the network. It uses a control protocol called Carrier Sense Multiple Access with Collision Detection and as all computer oriented people like to use acronyms the acronym used is CSMA/CD. The collision detection system works as described in the previous post under the Bus topology. The switched Ethernet doesn’t use CSMA/CD because collisions are impossible in its logical topology, a star. The switch, the central device, opens an connection between two nodes providing them with a full duplex connection. Because there is only two nodes collisions are impossible. The wireless Ethernet uses a central device called an access point. It is a wireless hub-based Ethernet. In other words it has a logical topology of a bus .A more in depth reasoning to why it falls underneath a bus topology is mainly because the node broadcasts the message and the access point listens to the message and re-broadcasts it so the intended node can listen. If there was other nodes in the area listening they can still be able to receive the message.   Because wireless Ethernet uses an unguided mean connectivity it is impossible to use CSMA/CD. Thus it uses a protocol called CSMA/CA; the CA stands collision avoidances.

What Transport Protocol ?

As promised in a previous post I am going to talk about the main differences between TCP, UDP, and SCTP. here is a  brief description of each:

The TCP

The TCP is an acronym for Transmission Control Protocol. This protocol provides a reliable transmission mechanism. The TCP connection occurs between a TCP client and a TCP server. The Client sends a request to open up a socket with the server, the server replies with an agreement. This handshake enables them to open a full duplex reliable connection. The connection is full duplex because data can flow in both directions. It is also reliable because you are assured that your packet is sent. The client provides the server with a sequence number and the server replies with an acknowledgment number. These numbers are used to make sure sent packets are received and provide the ability of packet switching. In other words data can be transferred using different routes and received not in the order sent. Even though   routing is the responsibility of the network layer, this protocol provides the connectivity and error checking…the network layer doesn’t provide with error checking nor is does it provide a reliable delivery service.

UDP

The UDP, or the User Datagram Protocol, is considered to be a connectionless and unreliable service. This protocol doesn’t divide the message, and it is the responsibility of the program to divide up the message. Each message is called a datagram, hence its name. The server sends each datagram independently and it is up for the client to discover if there was an error to request the datagrams to be sent again. This protocol is faster because it doesn’t take into consideration data correction. This is useful in video streaming, take for example Youtube; when streaming a video the datagrams of the video are sent simultaneously and if you, the user, realize that a later part of the video is displayed first no matter how many times you replay the video that would be the sequence of the clip. However if you refresh the page, requesting the page to reload you might fix the problem and receive all the datagrams in the order intended.

SCTP

Stream Control Transmission Protocol is similar to TCP however it includes the ability to send the multiple messages via the same connection. Theoretically the SCTP could replace the TCP; however it is currently only used in applications.

TCP/IP Network Model

In this post I will talk about the 5 different layers used in the TCP/IP network model. The TCP/IP is a set of protocols that are used for communication between several computers. It consists of five major layers, in each layer the data is isolated in such a way that the only relevant information is used. The layers are as follows:

Layer 5: Application Layer

All users are able to associate with the application layer. It is user friendly and consists of the message. An example of an address at its application layer is any URL for a given website. For example http://www.bentley.edu . Also the port number can be specified at the end of the application layer, although is more thought to be implemented at the beginning of the transport layer. With HTTP (hyper text transfer protocol) the standard port number is 80; however some websites use 8080 in order to secure some data, or make it unavailable for all users. There is more than one way to specify a port number. The easy way when using http is by adding a colon followed by the port number at the end of the URL. For example http://www.domainName.com:8080/

Layer 4: Transport Layer

This layer is responsible for the packetization of messages. Where the message is broken up into packets and put into “envelops” stamping it with address of the final destination.  This layer also is responsible for all end-to-end communication whether the message is sent using TCP, UDP, or SCTP protocols. I will elaborate more on the previous protocols in a later post.

Layer 3: Network Layer

In simple terms this layer is responsible for sending the message to the next address. Sometimes it is also referred to the IP layer. The protocol used here uses an unreliable best effort delivery service. In other words deliver is not guaranteed. One of the reasons it uses this services is because the error correction is found in the Transport Layer, and error checking at this state would “waste” time.

Layer 2: Data Link Layer

The data link layer is considered to be a physical layer. This layer is responsible for the reliable transmission of the message to the next node. It converts IP addresses to MAC addresses (medium access control). Every device has its own MAC address; as a matter of fact a personal computer has at least three MAC addresses, one for Ethernet, one for wifi and one for Bluetooth. This layer makes it possible to transmit data from one node to another. The packets at this layer are called frames.

Layer 1:  Physical Layer

This is where the transmission of the message actually takes place. This layer is implemented via hardware. Depending on the type of device connected to the network different methods are used. This is primarily why both the physical and data link layers are not defined by the TCP/IP and is depended on the underlying network.

Joining Hands

Clusters and multiprocessing systems are both very interesting topic, and makes one a person think of ways he can advance his home system with low costs. A cluster is a system where more than one computer is linked together and thought of one computer. There is a number of types of clusters.

The first type of cluster I’m going to talk about is tight coupling. Tight coupling is where multiple CPU’s share BUSes and input/output devices. An example of this type of cluster, even though we do not tend to think of it as a cluster is a personal computer with a dual core. Intel has provided the name with multiple cores. When there is more than one processor they may either be symmetric or follow the Master-slave model. As the name suggests in the symmetric model each CPU is in control, no other CPU is in charge. In the master-slave model there is a master CPU in which responsible in organizing the load.

In loose coupled systems each computer is thought to be able to stand alone; they do however share the tasks. In this system there are two models that can be used the share nothing model or the shared disk model. Their names explain how they work. With the shared disk model there must be a disk on some type of network or BUS that all computers are able to access.

Beowulf Clusters are very interesting. Despite their cool name, they are considered cost efficient. If someone is able to create a Commodity-Off-the-shelf Beowulf cluster a very powerful computer may be created. Google uses a Beowulf cluster, that said imagine the type of Beowulf cluster one may create at home for simple uses as a gaming computer.

Grid computer is also an interesting topic. I will not elaborate on this topic; however I will only include some information about how grid computing was used in research that the University of California at Berkley. An application was installed to computers, and when idle (screen saver was running) the installed software would use the computers CPU to analyze data, and return results to a huge database.

Disks

Disks are a very interesting matter of hardware to look at; especially the magnetic disk, in which a magnetic polarity is given to be able to store data including pictures, sound…etc the disk mechanism is simple, a disk that revolves around its axis, and a header that is relatively stationary. In relatively stationary I mean it only moves to the inside of the disk to the outside; changing the track it is reading.

As you might know the length of an arc on a circle is defined by the following:

Length of an arc = angle in radians * radius

Thus one may infer an inner track has a shorter length because the radius is shorter than that track on an outer track. (The circumference is the same the angle is 360 degrees or 2 pi radians) thus one would expect that an outer track would have more blocks or bits if they were packed as a tightly as the inner track. A problem occurs if this method is used if the disk is rotating at a constant speed because the head read/writes more bits on the outside than the inside when rotating the same angle. To fix this problem the outer blocks are packet loosely; meaning the number of bits on an inner block is equivalent to the number of bits on an outer block. This mechanism uses what is called a “constant angular velocity” in which the disk spins a certain angle (say 2pi in radians of course) at the same speed.

This fixes the problem; however it is not so efficient because you are wasting disk space, in the literal sense. If you pack the bits tightly together, using all the disk space you increase the efficiency of the use of the disk but then you would need the disk to rotate at different speeds on each track. This mechanism uses a constant linear velocity in which the head travels over a specific distance or arc length in a given time. The problem that arises here is how would the disk motor know what speed is necessary at which track.  This loses its efficiency in that you need to know where you are on the disk to be able to spin the disk at the required speed. To solve this problems some disks use zoning. In which each zone has a specified speed. This is like a common ground for not wasting as much “disk space” and not having to go through the hassle of figuring out the required disk speed on every track.

Interrupt – Excuse Me

In this post I will talk about interrupts and why they are essential to the computer. An interrupt may be thought of an exception in JAVA. The book defines it as a “signal that causes the CPU to alter its normal flow of instruction execution.”  Every time you move your mouse an interrupt occurs in which enables you to actually move the mouse. As you might know the processer on a computer can only do one thing at a time. When you move your mouse it “stops” what it is doing and moves the pointer according to your hand movement.  Because the processor is relatively fast, the user of the GUI doesn’t see the lag and feels that everything is run simultaneously; I will talk more about this in a later post.

Some of the uses of interrupts include*:

  • Notify that an external event has occurred
  • Signal completion
  • Allocate CPU time
  • Indicate abnormal event
  • Software interrupts

One of the most important interrupts is the Direct Memory Access. When accessing data on a disk the programmed I/O will start loading data into memory. The CPU has no way of knowing whether the disk controller has completed the transfer unless it is told so.  When the data transfer is completed the device shoots a completion interrupt telling the CPU that the data is ready to use. The interrupt here service as a point of communication. It is like saying “over” on a walkie-talky, informing the person on the other end you are done talking and giving him the flow of control to talk.

*taken from the PPTs

The Real Thing

In the previous post I talked about the LMC as a model. After understanding how the Little Man works it’s time to grow, and use more “realistic” terms. The LMC is a simplified model of how the computer works. The following is a list of what we find inside a computer:

  • MAR: Memory Address Register
  • MDR: Memory Data Register
  • IR: Instruction Register
  • PC: Program Counter
  • A: Accumulator, also known as the GPR, General Purpose Register
  • I/O: Input / Output

Because the Computer doesn’t hold actual “memory” as people do, we have to use a special register to “remember” what instruction is being executed; this is what the IR is for. The PC plays the same role as the counter in the LMC and the A is equivalent to the calculator. The MAR and the MDR can be described as the mail boxes. Where the MAR is the number of the mail box, and the MDR is the actual message inside that mail box.

The system works in a “Fetch-Execute Instruction Cycle.” As the name suggests the instruction is read, and then executed and after that the next instruction is read. It is based upon the transfer of data from one register to another. The Fetch cycle starts with the PC, the number is transferred to the MAR. The data in the MAR runs through a decoder, “lighting up” the particular line in memory where the MDR reads it and stores it. The Data in the MDR is transferred to the IR. The fetch part of the cycle is complete. The execute part of the cycle starts here. Depending on what the instruction is the computer executes it. If the instruction was to load a particular address, the data would then flow from the IR to the MAR, the same process happens in lighting up the line with that particular address.  It is stored in the MDR and then the data is transferred to the A. The execute part of the cycle is complete, now the program counter is updated and goes on to continue the cycle by fetching for the next instruction.

 

Little Man Computer

It has been a while since I last posted anything. Anyways, today I am going to write about the Little Man Computer (LMC). The LMC is a program that visually helps students understand how a computer works, it was created Dr. Stuart Madnick in 1965.

The little man has a calculator, a counter, In and Out baskets and a 100 mailboxes with zero based numbering. He opens each mail box, reads the OP-Code (operation Code) and executes that specific operation. This is what he can do:

  • Load
  • Store
  • Add
  • Subtract
  • Input
  • Output
  • Branch on Zero
  • Branch on Positive
  • Branch Unconditionally
  • Coffee Break / Halt

Combing these operations in a specified way create a program which runs the computer, essentially this is all what the computer does. The only true operations is add and subtract, the rest is either moving data around or branching to read other data.

The LMC model is useful for understanding the Von Neumann Architecture. There are three main guidelines that define this architecture. It includes the stored program concept, in which memory can hold both data and programs; in which the programs can be easily accessed and changed.  Also “memory is addressed linearly,”  in laymen terms memory locations are assigned a numeric address.  The third major guidline is the memory location has nothing to do with the data within that location.