Showing posts with label Computer Science. Show all posts
Showing posts with label Computer Science. Show all posts


What Is Operating System? Basic Idea of Operating System
What Is Operating System :

A program that acts as an intermediary along plus a devotee of a computer and the computer hardware.
Image result for cse

Goals of Operating Systems :
l1. Execute devotee programs and make solving devotee problems easier.
2. lMake the computer system convenient to use.

n
Objectives of Operating Systems :
1. To have enough keep a grand tour of the major full of zip systems components
2. nTo present coverage of basic computer system meting out


Operating System Structure :

nMultiprogramming needed for efficiency
lSingle user cannot sticking to CPU and I/O devices vivacious at all era
lMultiprogramming organizes jobs (code and data) therefore CPU always has one to slay
lA subset of quantity jobs in system is kept in memory
lOne job chosen and control via job scheduling
lWhen it has to wait (for I/O for example), OS switches to option job
nTime sharing (multitasking) is diagnostic intensification in which CPU switches jobs for that defense frequently that users can interact then each job though it is presidency, creating interactive computing
lResponse period should be < 1 second
lEach user has at least one program executing in memory [process
lIf several jobs ready to run at the same period [ CPU scheduling
lIf processes dont fit in memory, swapping moves them in and out to point of view
lVirtual memory allows play-engagement of processes not selected in memory

Graphs are networks consisting of nodes connected by edges or arcs. In directed graphs, the connections between nodes have a direction, and are called arcs; in undirected graphs, the connections have no direction and are called edges. We mainly discuss directed graphs. Algorithms in graphs include finding a path between two nodes, finding the shortest path between two nodes, determining cycles in the graph (a cycle is a non-empty path from a node to itself), finding a path that reaches all nodes (the famous "traveling salesman problem"), and so on. Sometimes the nodes or arcs of a graph have weights or costs associated with them, and we are interested in finding the cheapest path.
There's considerable literature on graph algorithms, which are an important part of discrete mathematics. Graphs also have much practical use in computer algorithms. Obvious examples can be found in the management of networks, but examples abound in many other areas. For instance, caller-callee relationships in a computer program can be seen as a graph (where cycles indicate recursion, and unreachable nodes represent dead code).
Few programming languages provide direct support for graphs as a data type, and Python is no exception. However, graphs are easily built out of lists and dictionaries. For instance, here's a simple graph (I can't use drawings in these columns, so I write down the graph's arcs): 
    A -> B
    A -> C
    B -> C
    B -> D
    C -> D
    D -> C
    E -> F
    F -> C
This graph has six nodes (A-F) and eight arcs. It can be represented by the following Python data structure:
    graph = {'A': ['B', 'C'],
             'B': ['C', 'D'],
             'C': ['D'],
             'D': ['C'],
             'E': ['F'],
             'F': ['C']}
This is a dictionary whose keys are the nodes of the graph. For each key, the corresponding value is a list containing the nodes that are connected by a direct arc from this node. This is about as simple as it gets (even simpler, the nodes could be represented by numbers instead of names, but names are more convenient and can easily be made to carry more information, such as city names). Let's write a simple function to determine a path between two nodes. It takes a graph and the start and end nodes as arguments. It will return a list of nodes (including the start and end nodes) comprising the path. When no path can be found, it returns None. The same node will not occur more than once on the path returned (i.e. it won't contain cycles). The algorithm uses an important technique called backtracking: it tries each possibility in turn until it finds a solution.

    def find_path(graph, start, end, path=[]):
        path = path + [start]
        if start == end:
            return path
        if not graph.has_key(start):
            return None
        for node in graph[start]:
            if node not in path:
                newpath = find_path(graph, node, end, path)
                if newpath: return newpath
        return None
A sample run (using the graph above):
    >>> find_path(graph, 'A', 'D')
    ['A', 'B', 'C', 'D']
    >>> 
The second 'if' statement is necessary only in case there are nodes that are listed as end points for arcs but that don't have outgoing arcs themselves, and aren't listed in the graph at all. Such nodes could also be contained in the graph, with an empty list of outgoing arcs, but sometimes it is more convenient not to require this. Note that while the user calls find_graph() with three arguments, it calls itself with a fourth argument: the path that has already been traversed. The default value for this argument is the empty list, '[]', meaning no nodes have been traversed yet. This argument is used to avoid cycles (the first 'if' inside the 'for' loop). The 'path' argument is not modified: the assignment "path = path + [start]" creates a new list. If we had written "path.append(start)" instead, we would have modified the variable 'path' in the caller, with disastrous results. (Using tuples, we could have been sure this would not happen, at the cost of having to write "path = path + (start,)" since "(start)" isn't a singleton tuple -- it is just a parenthesized expression.)
It is simple to change this function to return a list of all paths (without cycles) instead of the first path it finds: 
    def find_all_paths(graph, start, end, path=[]):
        path = path + [start]
        if start == end:
            return [path]
        if not graph.has_key(start):
            return []
        paths = []
        for node in graph[start]:
            if node not in path:
                newpaths = find_all_paths(graph, node, end, path)
                for newpath in newpaths:
                    paths.append(newpath)
        return paths
A sample run:
    >>> find_all_paths(graph, 'A', 'D')
    [['A', 'B', 'C', 'D'], ['A', 'B', 'D'], ['A', 'C', 'D']]
    >>> 
Another variant finds the shortest path:
    def find_shortest_path(graph, start, end, path=[]):
        path = path + [start]
        if start == end:
            return path
        if not graph.has_key(start):
            return None
        shortest = None
        for node in graph[start]:
            if node not in path:
                newpath = find_shortest_path(graph, node, end, path)
                if newpath:
                    if not shortest or len(newpath) < len(shortest):
                        shortest = newpath
        return shortest
Sample run:
    >>> find_shortest_path(graph, 'A', 'D')
    ['A', 'C', 'D']
    >>> 
These functions are about as simple as they get. Yet, they are nearly optimal (for code written in Python). In another Python Patterns column, I will try to analyze their running speed and improve their performance, at the cost of more code. Another variation would be to add more data abstraction: create a class to represent graphs, whose methods implement the various algorithms. While this appeals to the desire for structured programming, it doesn't make the code any more efficient (to the contrary). It does make it easier to add various labels to the nodes or arcs and to add algorithms that take those labels into account (e.g. to find the shortest route between two cities on a map). This, too, will be the subject of another column.

In laptop computers that lack USB 3.0 ports but have an ExpressCard slot, USB 3.0 ports can be added by using an ExpressCard-to-USB 3.0 adapter. Although the ExpressCard port itself is powered from a 3.3 V line, the connector also has a USB 2.0 port available to it (some express cards actually use the USB 2.0 interface rather than the true express card port). However, this USB 2.0 port is only capable of supplying the power for one USB 3.0 port. Where multiple ports are provided on the express card, additional power will need to be provided.
Additional power for multiple ports on a laptop PC may be derived in the following ways:
Some ExpressCard-to-USB 3.0 adapters may connect by a cable to an additional USB 2.0 port on the computer, which supplies additional power.
The ExpressCard may have a socket for an external power supply.
If the external device has an appropriate connector, it can be powered by an external power supply.
USB 3.0 port provided by an ExpressCard-to-USB 3.0 adapter may be connected to a separately-powered USB 3.0 hub, with external devices connected to that USB 3.0 hub.
On the motherboards of desktop PCs which have PCI Express (PCIe) slots (or the older PCI standard), USB 3.0 support can be added as a PCI Express expansion card. In addition to an empty PCIe slot on the motherboard, many "PCI Express to USB 3.0" expansion cards must be connected to a power supply such as a Molex adapter or external power supply, in order to power many USB 3.0 devices such as mobile phones, or external hard drives that have no power source other than USB; as of 2011, this is often used to supply two to four USB 3.0 ports with the full 0.9 A (4.5 W) of power that each USB 3.0 port is capable of (while also transmitting data), whereas the PCI Express slot itself cannot supply the required amount of power.
If faster connections to storage devices are the reason to consider USB 3.0, an alternative is to use eSATAp, possibly by adding an inexpensive expansion slot bracket that provides an eSATAp port; some external hard disk drives provide both USB (2.0 or 3.0) and eSATAp interfaces. To ensure compatibility between motherboards and peripherals, all USB-certified devices must be approved by the USB Implementers Forum (USB-IF). At least one complete end-to-end test system for USB 3.0 designers is available on the market

Private  -  Functions and variables to which only the class member functions (and friends) have access.
Public  -  Functions, and rarely non-constant variables, that are directly accessible through an object.
Protected  -  The protected keyword behaves the same as the private keyword, with the exception that protected variables are directly accessible from within subclasses.
Object  -  An object is an instance of a class; it is a variable with all the functionality specified in the class's definition.
Data Member  -  A data member is a variable declared in a class definition.
Member Function  -  Functions that belong to a class and operate on a its data members.
Constructor  -  The constructor of a class is the function that is called automatically when a new object is created. It should initialize the class's data members and allocate any necessary memory.
Destructor  -  A destructor is the function called when an object goes out of scope. It should free memory dynamically allocated for the object's data members.
Friend  -  A friend function is a function that has access to all the class's data members and member functions, including those under the private and protected headings.
Inheritance  -  Inheritance is the property exhibited when a subclass is derived from a superclass. In particular it refers to the fact that an instance of the subclass has all of the data members and member functions of the superclass (and possibly more).
Base Class  -  A base class is a class from which another class, called a derived class, inherits components.
Derived Class  -  A derived class is a class which has inherited the components of another class, called the base class.
Class Template  -  A class which has one or more data members (and functions) of some unspecified data type. By defining a template, the programmer can create an object using any data type or types.
Composition  -  Composition is the use of an object as a member variable of another class as an alternative to creating a subclass.
Virtual  -  A C++ key word used to qualify functions and inheritance.

Powered by Blogger.

Visitors

Print Friendly Version of this pagePrint Get a PDF version of this webpagePDF


 download University Notes apps for android

Popular Posts

Flag Counter