End-of-term review summary of embedded principles and applications (attached to a college final exam paper)


1. Multiple choice questions

1. In order to ensure that the DHCP process is automatically started when the server is started, the file (B) should be edited.
A. /etc/rc.d/rc.inet2 B. /etc/rc.d/rc.inet1
C. /etc/dhcpd.conf D. /etc/rc.d/rc.S

2. The access authority of the file exer1 is rw-r–r–, now it is necessary to increase the execution authority of all users and the write authority of users in the same group. The following command is correct ( A ).
A, chmod a+x g+w exer1 B, chmod 765 exer1
C, chmod o+x exer1 D, chmod g+w exer1

3. Delete the current directory abc and all subdirectories and files below, without prompting any confirmation information. The command is (B)
A. del abc*.* B. rm –rf abc C. rmdir abc D. rm –r abc\ .

4. If you forget the usage of the ls command, you can use the (C) command to get help
a.? ls b.help ls c.man ls d.get ls

5. The command to add executable attributes to file1 is ( C )
a.chmod a+x b.chown a+x c.chmod o+x d.chown o+x

6. How to create a new file: ( A )
a.touch hello.c b.mk hello.c c.rm hello.c d.new hello.c

7. In the bash command, when the (B) parameter is used, it means that bash is interactive.
A, -c B, -i C, -s D, -d

8. The redirection symbol ">" means: ( C )
A, output appending B, input appending C, output redirection, the original file will be rewritten D, pipeline

9. The partition types that can be directly read by the linux system are ( D )
a.ntfs b.fat16 c.fat32 d.ext3

10. In the ARM architecture, what method should be used to switch from the active user mode (User) to the super user mode (Supervisor)? C
A. Directly modify the mode corresponding to the CPU status register (CPSR)
B. First modify the program status backup register (SPSR) to the corresponding mode, and then update the CPU status
C. Use the software interrupt instruction (SWI)
D. Let the processor execute undefined define directive

11. The following descriptions of MMU and Linux are wrong: (c)
A. MMU is the abbreviation of Memory Management Unit
B. uClinux can run on processors with MMU
C. Linux kernel is powerful and has rich memory management functions , even on processors without an MMU, address mapping can be implemented by software.
D. The Linux system uses the MMU to enable each process to have an independent addressing space

12. In the command mode of the vi editor, to repeat the last operation on the edited text, you can use the (C) command.
A, up arrow B, down arrow C, <.> D, <*>

13. In the ARM Linux system, the exception mode used to handle peripheral interrupts is (C)
A. Software interrupt (SWI) B. Undefined instruction exception
C. Interrupt request (IRQ) D. Fast interrupt request (FIQ)

14. In the ARM Linux system, after the interrupt handler enters the C code, ARM is in __A__ working mode
A, super user (SVC) B, interrupt (IRQ)
C, fast interrupt (IRQ) D, and before entering the interrupt status is related

  1. In the ARM embedded system, the PC points to the instruction address being (C).
    A Execute B Decode C Fetch D Neither

  2. When the ARM system processes 16-bit data, the corresponding data type is ( B ).
    A Byte B Halfword C Word D None of the three

  3. A real-time system refers to ( B )
    A system with fast response B time-constrained system C single-task system D system with small kernel

  4. The following is the first stage of the blob running process: (C)
    A Peripheral hardware initialization (serial port, USB, etc.);
    B Enter the command line module or start the kernel according to the user's choice.
    Initialization of C registers
    Initialization of D stack

19. Among the following popular embedded GUIs, the one that does not adopt layered design is: (B)
A.MiniGUI B. Qt/Embedded C. Nano-X Window D. OpenGUI

20. When installing the source code release software package, when using the ./configure command to configure, if you need to install the software to the specified directory, you can use the parameters (A)
A–prefix B. --directory C. --temporary D.– install

21. In the ARM Linux system, after the interrupt handler enters the C code, ARM is in ( ) working mode (A)
A, super user (SVC) B, interrupt (IRQ)
C, fast interrupt (IRQ) D, and enter The state before the interrupt matters

22 Which of the following is the root directory of linux (B)
A, \ B, \bin C, \dev D, \etc

23. Which of the following commands can help you know the usage of shell commands (A)
A. man B. pwd C. help D. more

24. The command to add executable attributes to file1 is ( C )
A, chmod a+x B, chown a+x C, chmod o+x D, chown o+x

25. Among the following formulations, the one that belongs to the scope of the ifconfig command is (B).
A. Compile the source program B. Configure the IP address of the network card
C. Configure the system kernel D. Load the network card into the kernel

26. Which of the following methods is not a communication method between tasks in the Linux operating system. (C)
A, semaphore B, message queue C, mail D, shared memory

27. Generally, (C) can be used to realize automatic compilation.
A, gcc B, gdb C, make D, vi

28. Suppose the root user executes the "init 0" command, the system will (B).
A.pause b. shutdown c. restart d. initialization

29. The interface between the real-time operating system (RTOS) kernel and the application program is called (C).
A. Input/output interface B. File system
C. API D. Graphical user interface

30. In the process of using the GCC compiler, the following (B) option can be used to specify the generated target file name
A. -c B.-o C.-SD.-E

31. The command to save and exit vi is (D).
A, q B, q! C, w D, wq

32. The file permissions that can only be read by all users are (B)
A.777 B.444 C.644 D.640

33. The device driver is a part of the kernel. The following description is incorrect: (D)
A. The device driver completes the initialization and release of the device.
B. The device driver transfers data from the kernel to the hardware and reads data from the hardware.
C. The device driver reads the data sent by the application to the device file and returns the data requested by the application.
D. The device driver can make the user understand the details of the hardware more carefully.

34. The flag of the character device file type is ( B )
A. p B. c C. s D. l

35. In the ARM system structure, the smallest unit space for MMU mapping is _D___
A, 64KB​​​​, 16KB​​C, 4KB​D, 1KB

36. In most Linux distributions, which of the following is a block device ( B )
A. Serial port B. Hard disk C. Virtual terminal D. Printer

37. Regarding the installation and uninstallation of the file system, the correct description below is (A).
A. If the CD has not been uninstalled, the CD-ROM drive cannot be opened
B. The installation point of the file system can only be under /mnt
C. Regardless of whether there is a CD in the CD-ROM, the system can mount the CD-ROM device
D. mount /dev /fd0 /floppy The directory /floppy in this command is automatically generated

2. Fill in the blanks:

1. In the linux system, access the device as a file .

2. When installing the Linux system to partition the hard disk, there must be two partition types: file system partition and swap partition .

3. When using gdb to debug, you can use the step or next command to perform single-step execution.

4. DHCP can realize dynamic IP address allocation.

5. The vi editor has two working modes: command mode and input mode.

6. Before running the written shell program, the script file must be given execution permission.

7. In the Linux system, the directory used to store the configuration files and subdirectories required by the system is /etc .

8. The command to end the background process is kill .

9. The command for remote login is telnet .

10. When using vi to edit a file, save the file content into the test.txt file, and type in the command mode: w test.txt .

11. Under the Linux system, the hard disk (slave disk) of the second IDE channel is identified as hdb .

12. Using gcc to compile a c program to generate an executable file sometimes seems to be completed in one step, but it actually needs to go through the following four steps: preprocessing, compiling, assembling and linking .

13. When using gdb to debug, you can use the step or next command to perform single-step execution.

14. The kernel is divided into four subsystems: process management system, memory management system, i/o management system and file management system.

15. There are many inter-process communication methods used by linux, among which UNIX inter-process communication methods are (pipeline) and (well-known pipe), (signal signal); there are System V or POSIX inter-process communication methods (message queue ), (shared memory), (semaphore); the way of communication between different processes on different machines belonging to the network is (socket).

16. (Signal) is a software interrupt. It is the oldest communication mechanism between processes in the Unix system. It is often used to pass (asynchronous) signals between one or more processes.

17. When a signal appears, the system will operate in one of the following three ways: (ignore the signal), (capture the signal), (execute the default action of the system).

18. The signal set function group contains three main modules, which are (create function set), (register signal set), (detect signal set).

19. The general process of signal operation is (defining signal set), (setting signal mask bit), (defining signal processing function), (testing signal).

20. The implementation of the message queue includes four operations: (creating and opening the queue), (adding a message), (reading a message) and (controlling the message queue).

21. Classification of embedded software: (system) software, (support) software and (application) software.

22. There are two ways to run a process, namely (running independently) and (running with a parent process).

23. The Linux system is a multi-process system, and the processes have the characteristics of (parallelism) and (non-interference with each other). A process in linux contains three segments, namely (code segment), (data segment) and (stack segment).

24. The compilation of gcc can be divided into four stages: __preprocessing____, compilation, assembly and ___linking___.

25. In the Linux system, access the device as a file.

26. The Ping command can test whether the local system in the network can reach a remote host, so it is often used to test the connectivity of the network.

27. Embedded Linux systems can usually be divided into four levels from the software point of view: bootloader, __Linux kernel___, _file system , and user applications.

3. Interpretation questions:

1. The length of the Linux file name must not exceed 256 characters. (√)

2. Embedded CPU generally adopts unified addressing method to address I/O devices. (√)

3. A shell script can be regarded as a Linux job when it is running, and it may be completed by multiple processes. (√)

4. In the LINUX system, all content is expressed as files, and various methods of organizing files are called different file systems. (√)

5. The Linux system is a multi-user and multi-tasking time-sharing operating system that allows multiple users to run many programs on the same machine at one time. (√)

6. The main task of the daemon process is to complete the interaction with the user to ensure the responsiveness of the system. ( × )

7. The user program should have nothing to do with the actual physical device used. This feature is called device independence. ( × )

8. Ordinary processes can communicate with daemon processes through the pipeline mechanism. ( × )

9. In the application program, the interrupt method can be used to access the external I/O device. ( × )

10. Several states of the process can be transformed into each other. ( × )

11. In the Linux system, when a process forks () a new child process, the child process will inherit the parent process's process control block, process memory control information, file access information, context and other resources, that is, a full copy. ( × )

12. When the application layer considers the network programming model, TCP and UDP can be selected arbitrarily, as long as the debugging on the local loop (localloop) can pass the debugging. ( × )

13. The programming models of the application program and the driver program are completely different. The former uses the main() function as the entry point of the entire program, while the latter has no program entry point at all. ( × )

14. In order to improve the efficiency of CPU execution, the blocking method should be adopted for I/O device access as much as possible when the driver program is written; the non-blocking method should be adopted for the user process when the application layer program is written. ( × )

15. If the fork() system function is called successfully, there is only one return value, either 0 (in the child process) or the ID number of the child process. ( × )

16. Process ID 1 is usually the init process, which is called by the kernel at the end of the bootstrap process. The init process never terminates, it is a system process and runs with superuser privileges. ( × )

17. Generally speaking, it is uncertain whether the parent process or the child process executes first after fork, and it is completely random. ( × )

18. The creation of the pipeline exists in the form of a file node, so any process that is not among the ancestors of the process that created the pipeline will not be able to address it. ( × )

19. After the named pipe completes the task of inter-process communication, the system will recycle the resources and can no longer be read or written by any process. ( × )

19. In the command mode in the vi editor, use the d command to delete the character at the current cursor. ( × )

20. The root file system is an integral part of an embedded system with an operating system. ( × )

21. The main function of the file system is to realize virtual storage. ( × )

22.BootLoader is part of the embedded operating system. ( × )

23. The chmod command can be used to modify the operating mode of the processor. ( × )

24. The current ARM processor uses the Harvard architecture. (√)

  1. The operating mode of an ARM processor can be changed through interrupt or exception handling. (√)

26...BootLoader is part of the embedded operating system. (√)

27. All ports of STM32 have external interrupt capability. When using an external interrupt line, the corresponding pin must be configured as an output mode. ( × )

28. CISC is the abbreviation of Simplified Instruction Set Computer. RISC is an acronym for Complex Instruction Set Computer. ( × )

4. Short answer questions:

1. What is an embedded system? What are the characteristics of embedded systems?
Embedded system is application-centric, based on computer technology, and the software and hardware can be cut to meet the application system's strict requirements on function, reliability, cost, volume, and power consumption.
Features of embedded systems: specificity and extensiveness of application; intensive technology, knowledge, and capital; high efficiency; long life cycle; high reliability;

2. What are the design steps of an embedded system? What is the main job of each part?
(1) Requirements analysis phase, listing user needs;
(2) Architecture design phase, describing how the system functions are realized;
(3) Detailed design phase, classifying hardware systems and software systems to determine which functions Realize with hardware, which ones are realized with software;
(4) System integration, integrate the software, hardware and execution device of the system together, debug, find and improve errors in the design process
; A system is tested to see if it meets the given requirements.

3. What is the difference between program, process and thread?
A program is an executable code formed after compilation and is static. A process is an execution of a program that is active. A thread is an executable unit of a process, and different threads of the same process share the resources and address space of the process.

4. What commands are used to view and schedule processes?
The commands for process viewing are ps and top. The commands for process scheduling include at, crontab, batch, and kill.

5. It is known that the C language program has main program modules prog.c and prog.h, which call functions in another module subr.c and subr.h. Try to write a makefile that can compile these two modules into an executable file pr1.
pr1: prog.o subr.o
gcc –o pr1 prog.o subr.o
prog.o: prog.c prog.h
gcc –c –o prog.o prog.c
subr.o: subr.c subr.h
gcc –c –o subr.o subr.c

6. How to compile a C program in linux to make it an executable file? How to debug?
1) Check the directory where the .h file in the program is located, and add it to the system PATH;
2) Execute C compilation: #gcc [source file name] -o [object file name]
3) Change the target file to an executable file: # chmod +x [target file name]
4) If you need to execute multiple executable files continuously, you can use vi to generate a batch file, and finally remember to change the attribute of the batch file to executable (same as the previous step)
Debugging: use when compiling -g parameter, you can use gdb for debugging.

7. What is cross compilation? Why use cross-compilation?
The so-called cross-compilation refers to compiling on one platform to generate an executable program that runs on another platform. The reason for using cross-compilation is that the target platform does not have the conditions to directly run the development environment.

8. The difference between wait and waitpid functions:
before a subprocess terminates, wait makes its caller block, and waitpid has an option to make the caller not block. waitpid doesn't wait for the first child process to terminate—it has several options that control the specific process it waits for.

9. Daemon process programming rules (5 steps)
(1) Create a child process, and the parent process exits:
(2) Call setsid to create a new session and act as the leader of the session group.
(3) Change the current directory to the root directory
chdir ("/");
(4) Reset the file permission mask
umask (0);
(5) Close the file descriptor that is no longer needed.

10. What is the return value of Pid_t setsid(void)?
The function returns the process group ID on success, and -1 on error

5. Program Design Questions

1. Read the following shell program and write the execution result:
#!/bin/sh
for name in Tom Jack Harry
do
  echo “$name is my friend”
done
Answer:
Tom is my friend
Jack is my friend
Harry is my friend

2. Write a source program main.c in C language, (1) to open the file "test.txt" in the current directory, if the file is not created, and make it have read and write attributes, (2) write a The makefile implements automatic compilation and generates the executable file main. Note: header files can be ignored.

1、Void main(void)
{
    
    
	int fid;
	fid = open(./test.txt”,O_RDWR|O_CREAT); 
	if(fid==-1)
	{
    
    
		Printf(“open or create error \n”);
		exit(0);
}
Close(fid);
}
(2) objects = main.o 
	exec = main 
	all:$(objects)
		gcc –o $(exec) $(objects)
	main.o:main.c 
		gcc –c main.c 
	clean:
		rm –r $(exec) $(objects)

3. Programming to achieve the following functions
Main program hello.c (print Hello World!) The main program calls the message function through the header file hello.h
Header file hello.h (declare the message function) The message function is defined by message.c
Answer:
hello.c :

# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include "head.h"
int main (int argc,char *argv[])
{
    
    
        printf("Hello World!\n");
        message();
        return 0;
}

head.h:

void message(void);
message.c:
# include <stdio.h>
void message (void){
    
    
        printf("This is a message!\n");
}

4. The pipeline is a way of process communication in Linux. The following program creates a pipeline between the parent process and the child process, and then establishes communication between them to realize the function of the parent process writing data to the child process. Describes the function of the label line code.

int main()
{
    
    
	int pipe_fd[2];
	pid_t pid;
	char buf_r[100];
	char* p_wbuf;
	int r_num;
	memset(buf_r,0,sizeof(buf_r)); (1)         
     
if(pipe(pipe_fd)<0)      (2)                
{
    
    
	printf("pipe create error\n");
	return -1;
}
if((pid=fork())==0)3{
    
    
	printf("\n");
	close(pipe_fd[1]);4sleep(2);
	if((r_num=read(pipe_fd[0],buf_r,100))>0)  (5)         
	{
    
    
		printf(   "%d numbers read from the pipe is %s\n",r_num,buf_r);
	} 
close(pipe_fd[0]);6exit(0);
}
else if(pid>0)          (7)              
{
    
    
	close(pipe_fd[0]);8if(write(pipe_fd[1],"Hello",5)!=-1)9printf("parent write1 success!\n");
	if(write(pipe_fd[1]," Pipe",5)!=-1)
		printf("parent write2 success!\n");
	close(pipe_fd[1]);10sleep(3);
	waitpid(pid,NULL,0);
	exit(0);

(1) Clear the data buffer to 0 (2) Create a pipeline (3) Create a subprocess (4) Close the subprocess write descriptor (5) Subprocess read the content of the pipeline (
6) Close the subprocess read descriptor (7) The parent process runs the control statement
(8) closes the read descriptor of the parent process (9) writes data into the buffer (10) closes the write descriptor of the parent process

5. Write a source program main.c in C language, (1) to open the file "test.txt" in the current directory, if the file is not created, and make it have read and write attributes, (2) write a The makefile implements automatic compilation and generates the executable file main. Note: header files can be ignored.

1、Void main(void)
{
    
    
	int fid;
	fid = open(./test.txt”,O_RDWR|O_CREAT); 
	if(fid==-1)
	{
    
    
		Printf(“open or create error \n”);
		exit(0);
	}
	Close(fid);
}
(2) objects = main.o 
exec = main 
all:$(objects)
gcc –o $(exec) $(objects)
main.o:main.c 
gcc –c main.c 
clean:
rm –r $(exec) $(objects)

real test papers for colleges and universities

The first set

insert image description here
insert image description here
insert image description here
insert image description here

second set

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

third set

insert image description here
insert image description here
insert image description here
insert image description here

insert image description here

retake test paper

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

Follow/Like/Favorite to get more answers to real questions

Guess you like

Origin blog.csdn.net/Dustinthewine/article/details/129073317
Recommended