Saturday 3 March 2012

Principle of locality of reference

In computer science, locality of reference, also known as the principle of locality, is the phenomenon of the same value or related storage locations being frequently accessed. There are two basic types of reference locality. Temporal locality refers to the reuse of specific data and/or resources within relatively small time durations. Spatial locality refers to the use of data elements within relatively close storage locations.

1)    Temporal locality: if at one point in time a particular memory location is referenced, then it is likely that the same location will be referenced again in the near future. There is a temporal proximity between the adjacent references to the same memory location. In this case it is common to make efforts to store a copy of the referenced data in special memory storage, which can be accessed faster.

2)    Spatial locality: if a particular memory location is referenced at a particular time, then it is likely that nearby memory locations will be referenced in the near future. In this case it is common to attempt to guess the size and shape of the area around the current reference for which it is worthwhile to prepare faster access.

Reasons for Locality:-
1)Predictability: In fact, locality is merely one type of predictable behavior in computer systems. Luckily, many of the practical problems are decidable and hence the corresponding program can behave predictably, if it is well written.
2) Structure of the program: Locality occurs often because of the way in which computer programs are created, for handling decidable problems. Generally, related data is stored in nearby locations in storage. One common pattern in computing involves the processing of several items, one at a time. This means that if a lot of processing is done; the single item will be accessed more than once, thus leading to temporal locality of reference. Furthermore, moving to the next item implies that the next item will be read, hence spatial locality of reference, since memory locations are typically read in batches.
3) Linear data structures: Locality often occurs because code contains loops that tend to reference arrays or other data structures by indices. Sequential locality, a special case of spatial locality, occurs when relevant data elements are arranged and accessed linearly. For example, the simple traversal of elements in a one-dimensional array, from the base address to the highest element would exploit the sequential locality of the array in memory. 
Use of Locality in general :
    If most of the time the substantial    portion of the references aggregate into clusters, and if the shape of this system of clusters can be well predicted, then it  can be used for speed optimization





Tuesday 21 February 2012

How to remove unwanted entry from windows 7 boot manager

Hello Friends , If you want to remove unwanted entries from your boot manager in windows 7 then i have the solution ...




Please Follow it carefully....




1) open cmd ( run as administrator)




2) write command bcdedit




3)now after writing this command you will find list of many entries that are in your list when you open your pc..




4) now for example , if your boot loader as entry like earlier version of windows or ubuntu(though it is not exiting) you would like to remove this unwanted entries ...




5) for this write the following command...




bcdedit /delete {the key you want to remove} /cleanup

Note:- please keep space as shown above ...







here key= value that you will find after step 1 ; this value will be the value of identifier













TAKE CARE WHILE PERFORMING STEP 5....

Tuesday 14 February 2012

Personalize Your Windows Login Screen in windows 7

Hello Friends , Are you bored with your login screen ? All the time you login on your computer you have same background image ...

So, do you wanna change that image and set your favorite image as login screen , then follow this procedure ...

1) open windows start menu and type regedit and open it

2)go to following path

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background


3) right click on Background and select new -> DWORD(32-bit)Value

4)give name OEMBackground to newly created key

5) right click and select modify


6) set value equal to 1

7) go to following path-

C:\Windows\System32\oobe

8) go to info folder and open backgrounds folder

9) put your image(<256kb) in this folder and give name backgrounddefault.jpg

* it must be jpg file

10)your task is done ... log off your screen and again login .....



IF YOU LIKE THIS POST DO FOLLOW THIS BLOG...

FOR ANY PROBLEM PUT YOUR COMMENTS ....
















Saturday 4 February 2012

C++11 Standards

C++11, also formerly known as C++0x, is the name of the most recent iteration of the C++ programming language, approved by ISO as of 12 August 2011, replacing C++03. The name is derived from the tradition of naming language versions by the date of the specification's publication.

c++11 includes several additions to the core language and extends the C++ standard library, incorporating most of the C++ Technical Report 1 (TR1) libraries — with the exception of the library of mathematical special functions. C++11 was published as ISO/IEC 14882:2011 in September 2011 and is available for a fee. The most recent working draft freely available is N3242, dated 28 February 2011.



Changes from the previous version of the standard:-

  1. The modifications for C++ involve both the core language and the standard library. 
  2. Prefer introduction of new features through the standard library, rather than extending the core language. 
  3. Prefer changes that can evolve programming technique. 
  4. Improve C++ to facilitate systems and library design, rather than to introduce new features only useful to specific applications. 
  5. Increase type safety by providing safer alternatives to earlier unsafe techniques. 
  6. Increase performance and the ability to work directly with hardware. 
  7. Provide proper solutions for real-world problems. 
  8. Implement “zero-overhead” principle (additional support required by some utilities must be used only if the utility is used). 
  9. Make C++ easy to teach and to learn without removing any utility needed by expert programmers. 



Attention to beginners is considered important, because they will always compose the majority of computer programmers, and because many beginners would not intend to extend their knowledge of C++, limiting themselves to operate in the aspects of the language in which they are specialized.Additionally, considering the vastness of C++ and its usage (including areas of application and programming styles), even the most experienced programmers can become beginners in a new programming paradigm.



Extension to c++ core language:-


One function of the C++ committee is the development of the language core. Areas of the core language that were significantly improved include multi-threading support, generic programming support, uniform initialization, and performance enhancements.

For the purposes of this article, core language features and changes are grouped into four general sections: run-time performance enhancements, build-time performance enhancements, usability enhancements, and new functionality. Some features could fall into multiple groups, but they are only mentioned in the group which primarily represents that feature.




C11 standards

C11 (C1X) is an informal name for the current standard for the C programming language. It replaces the previous C standard, informally known as C99. This new version mainly standardizes features that have already been supported by common contemporary compilers, and includes a detailed memory model to better support multiple threads of execution. Due to delay availability of conforming C99 implementations, C11 makes more features optional, to make it easier to comply with the core language standard.


The final draft was published in April 2011. The new standard passed its final draft review on October 10, 2011 and was officially ratified by ISO and published as ISO/IEC 9899:2011 on December 8, 2011, with no comments requiring resolution from participating national bodies.


GCC version 4.6 has added initial support for some features from the C11 draft.


Changes from c99


  • Alignment specification
  • The _Noreturn function specifier
  • Type-generic expressions using the _Generic keyword. For example, the following macro cbrt(x) translates to cbrtl(x), cbrt(x) or cbrtf(x) depending on the type of x .
  • Multithreading support (_Thread_local storage-class specifier, <threads.h> header including thread creation/management functions, mutex, condition variable and thread-specific storagefunctionality, as well as the _Atomic type qualifier and <stdatomic.h> for uninterruptible object access).
  • Improved Unicode support based on the C Unicode Technical Report ISO/IEC TR 19769:2004 (char16_t and char32_t types for storing UTF-16/UTF-32 encoded data, including conversion functions in <uchar.h> and the corresponding u and U string literal prefixes, as well as the u8 prefix for UTF-8 encoded literals).
  • Removal of the gets function, deprecated in the current C language standard revision, ISO/IEC 9899:1999/Cor.3:2007(E), in favor of a new safe alternative, gets_s.
  • Bounds-checking interfaces .
  • More macros for querying the characteristics of floating point types, concerning subnormal floating point numbers and the number of decimal digits the type is able to store.
  • Anonymous structures and unions, useful when unions and structures are nested, e.g. in struct T { int tag; union { float x; int n; }; };.
  • Static assertions, which are evaluated during translation at a later phase than #if and #error, when types are understood by the translator.
  • An exclusive create-and-open mode ("…x") for fopen. This behaves like O_CREAT|O_EXCL in POSIX, which is commonly used for lock files.
  • The quick_exit function as a third way to terminate a program, intended to do at least minimal deinitialization if termination with exit fails.
  • Macros for the construction of complex values (partly because real + imaginary*I might not yield the expected value if imaginary is infinite or NaN)


Friday 20 January 2012

Make your vi editor work properly in ubuntu

Hello Friends,

if you are using ubuntu and you have problem of vi editor not working properly then don't worry .
I have a solution . You just have to install a package and that's all !!





1)first connect to internet

2)open your terminal then write the following command
$ sudo apt-get install vim


3)download the package ...
this is working for me.. Hoping it will work for you also.

Thursday 12 January 2012

Object Slicing



  • In object-oriented programming, a subclass typically extends its super class by defining additional member variables.

  •  If a super class instance is assigned its value from a subclass instance, member variables defined in the subclass cannot be copied, since the super class has no place to store them. This is a natural and unavoidable consequence of assignment by value from subclass objects.

  •  The term object slicing is sometimes used to refer to this aspect of assignment by value to a super class instance.

  • Object slicing is also used to refer to a more subtle, problematic, case in which an object assignment by value appears to be to a superclass instance but is actually to a subclass instance.

  •  From the perspective of object memory layout, the member variables of the source instance can be thought of as having been "sliced off", leaving the corresponding member variables in the destination instance unchanged.

  •  It is this partial assignment (arguably a more apt term) that often surprises programmers and leads to unintended consequences.

  • Unexpected object slicing can happen in languages such as C++ in which assignment by value is not polymorphic.

  •  It is not possible in Java, which allows object assignment only by reference, or the D programming language, which allows object inheritance only through reference types.

Example:

struct A
{
    A(int a) : a_var(a) {}
    int a_var;
};

struct B : public A
{
    B(int a, int b) : A(a), b_var(b) {}
    int b_var;
};

B &getB()
{
    static B b(1, 2);
    return b;
}

void example()
{
    // Normal assignment by value to a
    A a(3);
    a = getB();
    // a.a_var == 1, b.b_var not copied to a

    B b2(3, 4);
    A &a2 = b2;
    // Partial assignment by value through reference to b2
    a2 = getB();
    // b2.a_var == 1, b2.b_var == 4!
}