Sunday, August 31, 2014

Easy DDA Line Drawing Algorithm


DDA algorithm :


1. Define the nodes, i.e end points in form of (x1,y1) and (x2,y2).
2. Calculate the distance between the two end points vertically and horizontally, i.e dx=|x1-x2| and dy=|y1-y2|.
3. Define new variable name ‘pixel’, and compare dx and dy values,
4. if dx > dy then
pixel=dx
else
pixel =dy.
5. dx=dx/pixel
and dy=dy/pixel
6. x=x1;
y=y1;
7. while (i<=pixel) compute the pixel and plot the pixel with x=x+dx and y=y+dy.

 DDA ALGORITHM : PROGRAM


#include <graphics.h>
#include <stdio.h>
#include <math.h>

int main( )
{
    float x,y,x1,y1,x2,y2,dx,dy,pixel;
    int i,gd,gm;

    printf("Enter the value of x1 : ");
    scanf("%f",&x1);
    printf("Enter the value of y1 : ");
    scanf("%f",&y1);
    printf("Enter the value of x2 : ");
    scanf("%f",&x2);
    printf("Enter the value of y1 : ");
    scanf("%f",&y2);

    detectgraph(&gd,&gm);
    initgraph(&gd,&gm,"");

    dx=abs(x2-x1);
    dy=abs(y2-y1);

    if(dx>=dy)
    pixel=dx;
    else
    pixel=dy;

    dx=dx/pixel;
    dy=dy/pixel;

    x=x1;
    y=y1;

    i=1;
    while(i<=pixel)
    {
          putpixel(x,y,1);
          x=x+dx;
          y=y+dy;
          i=i+1;
          delay(100);
    }
    getch();
    closegraph();
}

Get 1000 Free YouTube Views For Your Video!

Wednesday, August 27, 2014

Root Finding Algorithms








BISECTION METHOD VIDEO


FAlSE POSITION METHOD VIDEO


                                                NEWTON RAPHSON METHOD


  

                                                       SECANT METHOD 

Tuesday, August 26, 2014

BISECTION ALGORITHM C CODES

Todays Code ::Numerical Method (Bisection Algorithm)

#include<stdio.h>
#include<conio.h>
#include<math.h>
#define f(x) x*x+4*x-10
#define E 0.0001
void main(){
clrscr();
float x1,x2,x0,f1,f2,f0,root;
int count=0;
printf("\t\t\t\tBisection Method\n");
initial:printf("Enter initial guesses x1 and x2\nx1 : ");
scanf("%f",&x1);
printf("\nx2 : ");
scanf("%f",&x2);
f1 = f(x1);
f2 = f(x2);

if((f1*f2)>0){
    printf("\nYour guesses are wrong. It can't be proceeded.\n");
    goto initial;
}
printf("Iteration\tX1\tX2\tX0\tf0\tf1\tf2\n");
      L:

count++;
printf("%d\t\t%.4f\t%.4f\t%.4f\t%.4f\t%.4f\t%.4f\n",count,x1,x2,x0,f0,f1,f2);
x0 = (x1+x2)/2;
f0 = f(x0);
       // printf("%d\n",count);
if((f0*f1)<0)
{
 x2 = x0;
 f2 = f0;
}
else
{
 x1 = x0;
 f1 = f0;
}
if(fabs((x2-x1)/x2)<E)
{
 root = (x1+x2)/2;
 printf("\nThe required root is %.4f",root);
}
else {
goto L;
}
getch();

Saturday, August 23, 2014

Evolution and History of Operating Systems

History of Operating Systems

In this section we take a brief look at the history of operating systems which is almost the same as looking at the history of computers. You are probably aware that Charles Babbage is attributed with designing the first digital computer, which he called the Analytical Engine. It is unfortunate that he never managed to build the computer as, being of a mechanical design; the technology of the day could not produce the components to the needed precision. Of course, Babbage‟s machine did not have an operating system, but would have been incredibly useful all the same for it‟s era for generating nautical navigation tables.


First Generation (1945-1955) : Like many developments, the first digital computer was developed due to the motivation of war. During the Second World War many people were developing automatic calculating machines. These first generation computers filled entire rooms with thousands of vacuum tubes. Like the analytical engine they did not have an operating system, they did not even have programming languages and programmers had to physically wire the computer to carry out their intended instructions. The programmers also had to book time on the computer as a programmer had to have dedicated use of the machine.


Second Generation (1955-1965): Vacuum tubes proved very unreliable and a programmer, wishing to run his program, could quite easily spend all his/her ti me searching for and replacing tubes that had blown. The mid fifties saw the development of the transistor which, as well as being smaller than vacuum tubes, was much more reliable. It now became feasible to manufacture computers that could be sold to customers willing to part with their money. Of course, the only people who could afford computers were large organizations who needed large air conditioned rooms in which to place them. Now, instead of programmers booking time on the machine, the

2


computers were under the control of computer operators. Programs were submitted on punched cards that were placed onto a magnetic tape. This tape was given to the operators who ran the job through the computer and delivered the output to the expectant programmer.


As computers were so expensive methods were developed that allowed the computer to be as productive as possible. One method of doing this (which is still in use today) is the concept of batch jobs. Instead of submitting one job at a time, many jobs were placed onto a single tape and these were processed one after another by the computer. The ability to do this can be seen as the first real operating system .


Third Generation (1965-1980): The third generation of computers is characterized by the use of Integrated Circuits as a replacement for transistors. This allowed computer manufacturers to build systems that users could upgrade as necessary. Up until this time, computers were single tasking. The third generation saw the start of multiprogramming. That is, the computer could give the illusion of running more than one task at a time. Being able to do this allowed the CPU to be used much more effectively. When one job had to wait for an I/O request, another program could use the CPU. The concept of multiprogramming led to a need for a more complex operating system. One was now needed that could schedule tasks and deal with all the problems that this brings. In implementing multiprogramming, the system was confined by the amount of physical memory that was available (unlike today where we have the concept of virtual memory). Another feature of third generation machines was that they implemented spooling. This allowed reading of punch cards onto disc as soon as they were brought into the computer room. This eliminated the need to store the jobs on tape, with all the problems this brings. Similarly, the output from jobs could also be stored to disc, thus allowing programs that produced output to run at the speed of the disc, and not the printer.



Although, compared to first and second generation machines, third generation machines were far superior but they did have a downside. Up until these point programmers were used to giving their job to an operator and watching it run. This problem led to the concept of time sharing. This allowed programmers to access the computer from a terminal and work in an interactive manner. Obviously, with the advent of multiprogramming, spooling and time sharing, operating systems had to become a lot more complex in order to deal with all these issues.



3


Fourth Generation (1980-present): The late seventies saw the development of Large Scale Integration (LSI). This led directly to the development of the personal computer (PC). These computers were (originally) designed to be single user, highly interactive and provide graphics capability. One of the requirements for the original PC produced by IBM was an operating system and, Bill Gates supplied MS-DOS on which he made his fortune. In addition, mainly on non-Intel processors, the UNIX operating system was being used. It is still (largely) true today that there are “mainframe” operating systems (such as VME which runs on ICL mainframes) and “PC” operating systems

(such as MS-Windows and UNIX), although the distinctions are starting to blur. Mainly, we can say that Graphical User Interface (GUI) became popular in 3rd generation computers.



Fifth Generation (Sometime in the future): If you look through the descriptions of the computer generations you will notice that each have been influenced by new hardware that was developed (vacuum tubes, transistors, integrated circuits and LSI). The fifth generation of computers may be the first that breaks with this tradition and the advances in software will be as important as advances in hardware. One view of what will define a fifth generation computer is one that is able to interact with humans in a way that is natural to us. No longer will we use mice and keyboards but we will be able to talk to computers in the same way that we communicate with each other. In addition, we will be able to talk in any language and the computer will have the ability to convert to any other language. Computers will also be able to reason in a way that imitates humans. Just being able to accept (and understand!) the spoken word and carry out reasoning on that data requires many things to come together before we have a fifth generation computer. For example, advances need to be made in AI (Artificial Intelligence) so that the computer can mimic human reasoning. It is also likely that computers will need to be more powerful. Maybe parallel processing will be required. Maybe a computer based on a non-silicon substance may be needed to fulfill that requirement (as silicon has a theoretical limit as to how fast it can go). This is one view of what will make a fifth generation computer. At the moment, as we do not have any, it is difficult to provide a reliable definition.

Types of Operating systems

Types of Operating systems

All of this history and development has left us with a wide variety of operating systems, not all of which are widely known.








Mainframe Operating Systems: A mainframe with 1000 disks and thousands of gigabytes of data is not unusual. Mainframes are normally used as web servers, servers for large-scale electronic commerce sites, and servers for business-to-business transactions. The operating systems for mainframes are heavily oriented toward processing many jobs at once, most of which need heavy amounts of I/O. They typically offer three kinds of services: batch, transaction processing, and timesharing.


A batch system is one that processes routine jobs without any interactive user present. A claim processing in an insurance company or sales reporting for a chain of stores is typically done in batch mode. Transaction processing systems handle large numbers of small requests; for example, check processing at a bank or airline reservations. Each unit of work is small, but the system must handle hundreds or thousands per second. Timesharing systems allow multiple remote users to run jobs on the computer at once, such as querying a big database. These functions are closely related: mainframe operating systems often perform all of them. An example mainframe operating system is OS/390, a descendant of OS/360


Real-Time Operating Systems: Another type of operating system is the real-time system. These systems are characterized by having time as a key parameter. For example, in industrial process control systems, real-time computers have to collect data about the production process and use it to control machines in the factory. Often there are hard deadlines that must be met. For example, if a car is moving down an assembly line, certain actions must take place at certain instants of time, if a welding robot welds too early or too late, the car will be ruined. If the action absolutely must occur at a certain moment (or within a certain range), we have a hard real-time system.


Another kind of real-time system is a soft real-time system, in which missing an occasional deadline is acceptable. Digital audio or multimedia systems fall in this category.


Personal Computer Operating Systems: Job of personal computer operating system is to provide a good interface to a single user. They are widely used for word processing, spreadsheets, Internet access etc. Personal computer operating systems are so widely known to the people who use computers but only few computer users knows about other types of operating systems. Common examples of PC operating systems are Windows 2008, Windows 2007, the Macintosh operating system, Linux, Ubuntu etc.






Server Operating Systems: Server operating systems run on servers, which are very large personal computers, workstations, or even mainframes. They serve multiple users at once over a network and allow the users to share hardware and software resources. Servers can provide print service, file service, or Web service. Internet providers run many server machines to support their customers and Web sites use servers to store the Web pages and handle the incoming requests. Some Examples of typical server operating systems are UNIX and Windows 2007 server, Sun Solaris etc.


Friday, August 22, 2014

What is an Operating System?

What is an Operating System?

If we just build a computer, using its basic physical components, then we end up with a lot of assembled metal, plastic and silicon. In this state the computer is useless. To turn it into one of the most useful tools we need software. We need applications that allow us to write letters, write software, perform numerical modeling, calculate cash flow forecasts etc etc. But, if all we have are just the applications, then each programmer has
to deal with the complexities of the hardware. If a program requires data from a disc,the programmer would need to know how every type of disc worked and then be able to program at a low level in order to extract the data. In addition, the programmer would have to deal with all the error conditions that could arise. For example, it is a lot easier for a programmer to say READ NEXT RECORD than have to worry about: spinning the
motor up, moving the read/write heads, waiting for the correct sector to come around and then reading the data.It was clear, from an early stage in the development of computers, that there needed to be a “layer of software” that sat between the hardware and the software, to hide the user
from such complexities, and to hide the „breakable‟ parts of the computer from human error or stupidity. Thus we can define operating system as “It is the system software that acts as a interface between computer hardware and users and provides easy interface to the users by hiding underlying complexities of computer hardware “


Two views of an operating system


Now we are going to look at two views of an operating system. In another word we can categorize functions of an operating system into two categories

OS as Resource Manager:

 One view considers the operating system as a resource manager. In this view the operating system is seen as a way of providing the users of the computer with the resources they need at any given time. Some of these resource requests may not be able to be met (memory, CPU usage etc.) but, the operating system is able to deal with problems such as these. For example consider the situation where more than one process is requesting CPU. If we have single CPU it can be assigned to only one process at a time. OS is responsible for when to provide CPU to which process called CPU scheduling. Similarly other resources are also managed by CPU.

OS as Extended Machine:

Another view of an operating system sees it as a way of not having to deal with the complexity of the hardware. If we have operating system,we can read data easily from disc by issuing a command such as READ. But, if we don‟t have OS we have to deal with low level complexities f disc to read data from it.We should know whether the floppy disc is spinning, what type of recording method we should use, What error codes are used etc etc. Operating system hides all these complexities from us simple minded users and provides convenient interface. So in this view of the machine, the operating system can be seen as an extended machine or a virtual machine.