20,129-month Written summary

Source: Internet
Author: User
Tags numeric value volatile

2012.9.16 Rui Sheng Written test:
1. Macro definition: Ask how many seconds a year.
#define (365*24*60*60) UL
Is that the UL special attention, at that time forgot to write

2. Write out the three examples of volatile

Precisely, the optimizer must carefully retrieve the value of the variable every time it uses it, instead of using a backup stored in the register. Here are a few examples of volatile variables:

1 hardware registers of parallel devices (e.g. state registers)
2 non-automatic variable (non-automatic variables) that is accessed in an interrupt service subroutine
3 variables shared by several tasks in multi-threaded applications

2012.9.17 Huawei Interview:
1. A virtual pointer is a high or a bottom address placed in the object's memory.
This experiment with the GCC compiler on Linux, the virtual pointer is placed at the beginning of the object's first place, followed by the data members.

2. How to view the Linux system default stack (number of file handles) size. How to change. The biggest is how much.

Ulimit-a
Core file size (blocks,-c) 0
Data seg Size (Kbytes,-D) Unlimited
Max Nice (-e) 0
File size (blocks,-f) Unlimited
Pending Signals (I.) 16384
Max locked Memory (Kbytes, L) 32
Max memory Size (Kbytes, M) Unlimited
Open files (-N) 1024//A process the maximum number of open file handles
Pipe Size (bytes, p) 8
POSIX message queues (bytes,-Q) 819200
Max RT Priority (-R) 0
Stack size (Kbytes,-s) 10240//default stack size 10M
CPU time (seconds,-t) unlimited
MAX User Processes (-u) 16384
Virtual Memory (Kbytes,-V) Unlimited
File locks (-X) Unlimited

You can view the default stack space size for Linux by command ulimit-s m
1 by the command ulimit-s set the size value temporarily change the stack space size: Ulimit-s 102400, that is, modified to 100M (for the file handle is also ulimit-n), but the restart or user exit will revert to the original appearance.
2) You can add Ulimit-s 102400 in the/etc/rc.local to set the stack space size on the boot
3 in the/etc/security/limits.conf can also change the stack space size.

Ulimit-n 1048576 This is the largest process on my Linux system open file handle value, that is, 1g,1024*1024, concurrent 100w, which means that my operating system as a server, if the single process multithreading concurrency, So the largest number of connections is a little more than 100w, in fact, has been very cow single server.

3.UML draw a World of Warcraft model
This is a little difficult.

2012.9.22 ZTE

1. The protocol used by streaming media is: C
A, SDP B, PPP C, RTSP D, FTP

RTSP (real Time streaming Protocol), a real-time streaming transport protocol, is an application layer protocol in the TCP/IP protocol system, which is submitted by the Columbia University, Netscape and RealNetworks company to the IETF RFC standard. This protocol defines how a one-to-many application can efficiently transfer multimedia data over an IP network. RTSP is on the architecture of RTP and RTCP, which uses TCP or RTP to complete data transfer. HTTP transmits HTML compared to RTSP, while RTSP transmits multimedia data. HTTP requests are sent by the client, the server responds, and when the RTSP is used, both the client and the server can make requests, that is, the RTSP can be two-way.

The Point-to-Point Protocol (English: point-to-point PROTOCOL,PPP) works at the Data Link layer (in the view of the OSI Reference Model). It is typically used to create a direct connection between two nodes. It is mainly used to connect two computers using serial lines, and it is now useful in broadband computer connections. Many Internet service providers (ISPs) use PPPoE to provide access to users (for example, access to the Internet has largely replaced the old Peuchun slip).

After the PPP protocol was designed in HDLC protocol, it was designed to replace the non standard protocol slip of the data link layer. Its designers include many additional features that were not considered in the data link layer protocols on the WAN at the time. It is therefore designed to be very flexible: it is used as a data link layer (Layer 2) protocol to support both synchronous link connections and asynchronous link connections, and can support multiple network layer protocols such as IP, IPX, and AppleTalk. In addition to the basic frame function, the PPP protocol includes two parts: Link Control Protocol and network control protocol.

2.restrict It can only be used to qualify and constrain pointers, and indicates that the pointer is the only and initial way to access a data object. That is, it tells the compiler that all operations that modify the contents of the pointer to the memory must be modified by the pointer and not by other means (other variables or pointers); The advantage of doing so is that it can help the compiler to better optimize the code and generate more efficient assembly code. such as int *restrict ptr, ptr-pointed memory units can only be accessed by PTR, any other pointers to this memory unit are undefined, and a straightforward point is an invalid pointer.

3. Two pointers can not be added, can be subtracted, can be compared.

4. The definition of a function cannot be nested, and calls can be nested. You cannot nest definitions even in the main function, but you can declare a function in main and in other function bodies.

5. Conflict resolution techniques can be divided into two categories: open hashing (open hashing, also known as zipper method, separate chaining) and closed hashing (closed hashing, also known as open address method, open addressing). The difference between the two methods is that the hashing method stores the conflicting key code outside the hash table, and the closed hashing stores the conflicting keys in another slot in the table.

Load factor = number of records loaded in the table/hashtable length (smaller loading factor, less conflict)

6. In polymorphism, the return value of a subclass's virtual function must be the same as that of the parent class, or it will compile an error.

7. Static variables can be declared and initialized in the header file, can be included in multiple CPP files, multiple CPP files for the same variable, change a value, other values will change. This time, in fact, Static has lost its role.

8. Assuming that there are consortia A and B, you can a=b such a whole assignment, but you cannot directly cout<<a<<endl; the output of such a whole.

9.
const int a = 1;
int *b = (int *) &a;
*b = 2;
cout<<a<<endl;
cout<<b<<endl;
First output 1, in the output 2. On the Internet to find the resolution:
const int a=1; If we don't have an address to a or any other operation related to a address, a constant variable in memory does not exist, that is, the memory is not a assigned address. When the program runs, all a in the code is replaced directly with 1, which saves memory and facilitates operation. But if you operate on the address of a, for example: int *b = (int *) &a; then a will create variable a in memory so that we can manipulate the memory address of a and its contents. But according to the above argument, pointer B = &a, why the content of pointer B is different from the contents of a. Why the same address, the output value is not the same. This should be the const mechanism of C + +. A variable is created in memory by a when an address action is performed on a. But the const still tells a: "Although you created a variable in memory, you can only use this in-memory a variable when someone wants to do something related to your address, and you still have to replace all the other A in the code with 1." "In other words, the code in the case of a address-independent operation, then the code of a or directly replaced by 1; In general code in the case of a address-related operations, then the use of a is actually in memory variable A." (Note: An int a=1 is stored in the memory address, not a const int a=1,const is just a mechanism, not a data type.) )

10. Some of the contents of I/O registers and ordinary RAM:
1 The only difference between I/O operation and memory operation is that the i\o operation has a marginal effect (seemingly the side effects).
2 The only result of a memory write operation is to store a numeric value at the specified location.
3 When the memory is optimized, the process is transparent and works well, but it can cause fatal errors for I/O.

This is a multiple-choice, online check is an English book translation content, the problem is too unreliable also, the internet to find someone else's translation:

Although there is a strong similarity between hardware registers and memory, programmers should be extra cautious when accessing I/O registers, avoiding being confused by CPU (or compiler) optimizations because it may modify the I/O behavior you expect.
A major difference between I/O registers and RAM is that I/O operations can have side effects and memory operations do not. The only effect of a memory write operation is to store a value to an address, and a memory read operation returns the last value written to that address. Because memory access speeds are critical to CPU performance, this operation without side effects has been optimized in a number of ways: values are cached and read/write instructions are rearranged.
The compiler is able to cache data values to CPU registers without writing to memory, and even if the data values are already stored in memory, both read and write operations can be performed in buffered memory rather than direct contact with physical RAM. In addition, instruction rearrangement may occur at the compiler level or at the hardware level: In many cases, if a directive is executed in a different order than it appears in the text of the program (for example, to avoid interlocking in the RISC pipeline), it can perform faster
For traditional memory (at least in a single-processor system), these optimizations are transparent and beneficial. The main purpose of driving direct access I/O registers is to improve CPU performance. However, these optimizations can be fatal for proper I/O operations. The processor cannot foresee this, and some other operations (running on a stand-alone processor, or something happening on an I/O Controller) depend on the order in which memory is accessed. The compiler or CPU may only try to outdo you and rearrange the actions you request; The result may be a strange mistake and very difficult to debug. Therefore, a driver must ensure that no buffering is done and that no read or write rearrangement occurs while accessing the registers.

2012.9.23 Newland
1.linux command
Od-dump files in octal and other formats
Vim-This is vim, namely VI
2. Friend
Friend function, Friend class, and so on are private relations, can not pass, inheritance, transfer and other relations to create a new friend relationship, in other words, this relationship is no matter what method can not inherit and pass.

2012 9.24 Kay Ishun

1. Output results
#include <iostream>
#include <list>
#include <set>
using namespace Std;

int main ()
{
Char s[100] = "US";
Char name[100] = "Angle";
sprintf (S, "%s join%s", name, s);
cout<<s<<endl;
return 0;
}
is: Angel join Angel Join

2. Declares a function that returns a float array pointer, assuming that the array pointer points to a float array with 10 elements
Should be: Float (*f ()) [10]
Float (*p) [10];
p = f (); Ok

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.