2020 Hikvision Embedded Software Engineer Interview Questions

//If you do something wrong, please leave a message
1. Compared with C language, the portability of assembly language (C)

  • Same
  • don't know
  • poor
  • better

Analysis:
Assembly is closely related to the current hardware architecture. For example, the assembly you write for x86 CPU cannot be used on ARM (instructions, registers, etc. are all different). Assembly for a 32-bit CPU cannot be used on a 16-bit CPU even with the same architecture. Assembly is not at all portable.
The C language itself is hardware architecture independent, so it is portable. C compilers under different platforms can convert the general-purpose C language into assembly language under the corresponding platform (x86, arm, etc.). (For example, the commonly used compiler gcc can use gcc -S ac to convert ac into the corresponding assembly as)

2. The error described below is ()

  • The public member set becomes the interface of the class
  • private members can be accessed outside the class
  • Class members are determined by private, protected, and public access characteristics
  • All members can be accessed externally

* 3. Regarding the statement char ptr = malloc(0), the following description is wrong (C)

  • When returning a specific memory value, ptr occupies a certain amount of memory space
  • may return a specific value
  • may return NULL
  • When returning a specific memory value, the memory space occupied by ptr cannot be used or released

Analysis
When malloc is used, NULL will only be returned if there is not enough memory, or an exception will be reported to
malloc(0), indicating that the system has prepared for you. The starting address used in the stack is just not allowed to read and write,
NULL Generally defined as (void *) 0, pointing to the address of 0, malloc is the program allocates space in the stack, it will not be 0 address
For example:
int pp =(strlen((ptr=(char *)malloc(0))0 display Error
malloc(0) refers to the allocated space memory size is 0
NULL does not point to any entity
mallo(0) is also an existence is not NULL

**4. Suppose char test[8]={0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08};int test_p = (int )test expression int a=test_p[1]; in big endian mode Stored at the memory address of 1000~1003H, then what is stored at 1000H is (D)

  • 0x01
  • 0x02
  • 0x05
  • 0x08

5. There is the following structure in the 32-bit system:
typedef struct{ int a; float b; char c[253]; double d; char f[35]; long int e; short g; short *ptr; int *ptr2; short h[33]; char *ptr3; }HKVISION;sizeof(HKVISION)? How to optimize? ?

400
优化
int a;
float b;
double b;
long int e;
char *ptr3;
short *ptr;
int *ptr2;
char c[253];
char f[35];
short h[33];
short g;

insert image description here

Knowledge points
The difference lies in the pointer char * long and unsigned long

32-bit compiler:

  char :1个字节
  char*(即指针变量): 4个字节(32位的寻址空间是2^32, 即32个bit,也就是4个字节。同理64位编译器)
  short :2
  short int : 2个字节
  int:  4个字节
  unsigned int : 4个字节
  float:  4个字节
  double:   8个字节
  long:   4个字节
  long long:  8个字节
  unsigned long:  4个字节

64-bit compiler:

  char :1个字节
  char*(即指针变量): 8个字节
  short int : 2个字节
  int:  4个字节
  unsigned int : 4个字节
  float:  4个字节
  double:   8个字节
  long:   8个字节
  long long:  8个字节
  unsigned long:  8个字节

5. What threads in the Linux system cannot be shared (C)

  • global variable
  • heap
  • the stack
  • file handle

Test points
The difference between process and thread - recitation

6. The description of the binary tree is correct (D)

  • The depth of the binary tree does not exceed 256
  • A full binary tree is also called a complete binary tree
  • Binary tree subtrees have no left or right distinction
  • A binary tree has at most two subtrees per node

Binary tree knowledge points
https://blog.csdn.net/u013834525/article/details/80506126

7. The working principle of TCP is wrong (D)

  • Application data is segmented into chunks of data that TCP deems most appropriate to send
  • TCP provides flow control
  • TCP keeps his header and data checksum, which is an end-to-end checksum
  • The TCP segment is transmitted as an IP datagram, and the IP datagram may arrive out of order, so the TCP message may arrive out of order. In this case, the application layer receives out of order

8. MTU specifies the maximum size of data packets that can be transmitted in the network, commonly used in Ethernet, MTU is a few bytes (A)

  • 1500
  • random
  • 1024
  • 100

Here it must be distinguished from the IP port - the 65536
protocol can also correct
the mss

9. The maximum addressing space of a 32-bit program is (C)

  • 2G
  • 1G
  • 4G
  • 8G

2^32=4G

10. What the cpu can execute is (D)

  • machine language execution
  • Machine Language vs. Assembly Language
  • Machine Language vs. Assembly Language vs. Hardware Description Language Programs
  • Machine language and hardware description language programs

11. Let’s take a look at the ways to achieve inter-process communication (ABC) under the Linux system

  • Socket
  • pipeline
  • Signal
  • global variable

12. The description of Head and Stack memory space is correct (CD)

  • The maloc space allocation in c is in the stack
  • Parameters are passed on the stack when the function is called during the running of the program
  • Stack space allocation is automatically allocated by the operating system
  • Manual allocation and release of space on the heap

13. Which of the following statements about the interrupt processing function is correct (AC)

  • Interrupt handler has no return value
  • Interrupt handlers can have return values
  • The interrupt handler has no parameters
  • Interrupt handlers can have parameters

14. The following description is correct (ABD)

  • When calling a function, the actual parameter and formal parameter types can be inconsistent
  • When calling a function, the actual parameter can be an expression
  • When calling a function, the actual parameter and the formal parameter can share the memory unit
  • When a function is called, the program allocates memory space for the actual and formal parameters

I feel that actual parameters and formal parameters can be the same or different.
Formal parameter variables are only allocated memory units when they are called, and the allocated memory units can be released at the end of the call. Therefore, formal parameters are only valid inside the function. After the function call ends and returns to the calling function, the formal parameter cannot be used anymore. The
actual parameter can be constant, variable, expression, function, etc. No matter what type of quantity the actual parameter is, they must be used when calling the function. Have definite values ​​to pass to the formal parameters.
Therefore, methods such as assignment and input should be used in advance to obtain a definite value for the actual parameter.
The data transfer that occurs within a function call is one-way. That is, the value of the actual parameter can only be transferred to the formal parameter, but the value of the formal parameter cannot be transferred back to the actual parameter. Therefore, during the function call, the value of the formal parameter changes, but the value in the actual parameter does not change

15. There is only one array table, please use the macro definition to find the number of array elements
#define N (sizeof(table)/sizeof(table[0]))
16. The difference between process and thread

  • A process is the smallest unit of system resource allocation, and a thread is the smallest unit of program execution
  • A process has its own independent address space. Every time a process is started, the system will automatically allocate data segments, code segments, and stack segments for him. This operation is very expensive, and threads and processes share the same resources and only have their own local variables ( stack), shared global variables and heap, file handles, etc., so cpu spends threads significantly less than processes
  • Thread communication is much more convenient than processes, but synchronization and mutual exclusion need to be handled well, and IP C is required under the same process
  • Multi-process is not easy to make the program crash, and the thread is easy to cause the program to crash because one thread is dropped

**16. The program realizes the definition of the single linked list node Link insert link *insertElem(link *p, int elem, int add), query int findElem(link *p, int elem) delete link deleteElem(link p, int add )

typedef struct node{
	int elem;
	struct node *next;
}link;
link *insertElem(link *p,int elem,int add){
	//操作变量临时
	link *temp = p;
	//先找到要插入节点的位置
	for(int i=0;i<add;i++){
		if(temp=NULL){
			printf("the position is invalid");
			return p;
		}
		temp=temp->next;
	}
	//创建插入的节点
	link *c=(link *)malloc(link);
	c->elem=elem;
	//进行插入,先把尾巴查起来
	c->next = temp->next;
	temp->next=c;
	return p
}
int findElem(link *p,int elem){
	while(p->next !=NULL){
		if(p->elem == elem){
			printf( "I have find the elem %d",p->elem);
			return p->elem;
		}
				p=p->next;
	}
	printf("not found!!\n");
	return 0;
}

link *delete(link *p,int add){
	link *temp=p;
	link *pre_node=p;
	if(add==0){//说明是头节点
		p=p->next;
		free(temp);
		return p;
	}else{
		for(int i=0;i<add;i++){
			//记录链表的上一个节点
			pre_node=temp;
			temp=temp->next;
		}
		if(p->next == NULL){//说明是尾巴节点
			pre_node->next=NULL;
			free(temp);
			return p;
		}else{//中间节点
			pre_node->next=pre_node->next-next;
			free(temp);
			return p;
		}

	}
	
}

Guess you like

Origin blog.csdn.net/weixin_40178954/article/details/100632747