TCS Papers: Sample Questions 440 - 442 of 502

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 440

» Languages » C & C Plus Plus

Short Answer Question▾

Write in Short

Can static variables are declared in a header file?

Explanation

  • You can’t declare a static variable without defining it as well.

  • This is because the storage class modifiers static and extern are mutually exclusive.

  • A static variable can be defined in a header file, but this would cause each source file that included the header file to have its own private copy of the variable, which is probably not what was intended.

  • The static variables don’t have external linkage which means they cannot be accessed outside the translation unit in which they are being defined.

Question number: 441

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

Name of the classes that are introduced in the System. Numerics namespace.

Explanation

  • The following two new classes are introduced in the System. Numerics namespace.

  • BigInteger -

    • Non-primitive integral type to hold a value of any size.

    • No lower and upper limit allowing arithmetic calculations with very large numbers which cannot be held by double or long.

    • Complex –

  • Represents complex numbers enabling arithmetic operations with complex numbers.

  • Complex number is represented in the form a + bi, where a is the real part and b is the imaginary part.

Question number: 442

» Basic CS » Operating System

Essay Question▾

Describe in Detail

What is the Translation Lookaside Buffer (TLB)?

Explanation

  • In a cached system, the base addresses of the last few referenced pages is maintained in registers called the TLB that aids in faster lookup.

  • TLB contains those page-table entries that have been most recently used.

  • Normally, each virtual memory reference causes physical memory accesses- one to fetch appropriate page-table entry, and one to fetch the desired data.

  • Using TLB in-between, this is reduced to just one physical memory access in cases of TLB-hit.

  • A translation Lookaside buffer (TLB) is a memory cache that stores recent translations of virtual memory to physical addresses for faster retrieval.

  • When a virtual memory address is referenced by a program, the search starts in the CPU.

  • First, instruction caches are checked. If the required memory is not in these very fast caches, the system has to look up the memory’s physical address.

  • At this point, TLB is checked for a quick reference to the location in physical memory.

  • When an address is searched in the TLB and not found, the physical memory must be searched with a memory page crawl operation.

  • As virtual memory addresses are translated, values referenced are added to TLB.

  • When a value can be retrieved from TLB, speed is enhanced because the memory address is stored in the TLB on processor.

  • Most processors include TLBs to increase the speed of virtual memory operations through the inherent latency-reducing proximity as well as the high-running frequencies of current CPU’s.

  • TLBs also add the support required for multi-user computers to keep memory separate, by having a user and a supervisor mode as well as using permissions on read and write bits to enable sharing.

  • TLBs can suffer performance issues from multitasking and code errors. This performance degradation is called a cache thrash.

  • Cache thrash is caused by an ongoing computer activity that fails to progress due to excessive use of resources or conflicts in the caching system.

Image of The Translation Lookaside Buffer (TLB)

Image of the Translation Lookaside Buffer (TLB)

Given the image is defining the Translation Lookaside Buffer (TLB).