1 readProgramTo answer questions
Int main (INT argc, char * argv [])
{
Int c = 9, D = 0;
C = C ++ % 5;
D = C;
Printf ("d = % d \ n", d );
Return 0;
}
A) Write Program output
B) Is this expression risky in a portable system? Why? # Include "stdio. H"
Int A = 0;
Int B;
Static char C;
Int main (INT argc, char * argv [])
{
Char d = 4;
Static short E; A ++;
B = 100;
C = (char) ++;
E = (++ d) ++;
Printf ("A = % d, B = % d, c = % D, D = % d, e = % d", a, B, c, d, e );
Return 0;
}
A) Write Program output
B) if the compiler arranges the layout of each variable (A, B, C, D) in the memory (eg. Stack, heap, data section, BSS section), it is best to use a Graphical description. 2. interruption is an important part of embedded systems, which leads to many compilation developers to provide an extension: To interrupt Standard C support, a New Keyword _ interrupt is generated. The followingCodeThe _ interrupt keyword is used to define an interrupt service subroutine (ISR). Please comment on the following code.
_ Interrupt double compute_area (double radius)
{
Double area = pI * radius;
Printf ("narea = % F", area );
Return area;
} 3 C/C ++ basic knowledge
A) What is the meaning of the keyword volatile during compilation? Three examples of different use cases are provided (which can be pseudo-code or text description ).
B) What are the specific functions of the static keyword in C language?
C) What is the difference between the following three variable declarations? Please give the specific meaning
Int const * P;
Int * const P;
Int const * const P; 4 embedded system problems
A) for integer variables A = 0x12345678, draw out how to store them in memory in the little endian and big endian modes.
B) In the arm system, which method does the Parameter Pass when a function is called?
C) What is the difference between an interrupt (interrupt, such as a keyboard interrupt) and an exception (exception, such as a division by zero exception? 5. Set the periodic tasks P1, P2, and P3 to T1, T2, and T3 to 100,150,400 respectively, and the execution time to 20, 40, and 100 respectively. Design a Scheduling MethodAlgorithmSchedule Tasks to meet the task execution cycle and task cycle. 6 priority reversal is a serious problem in embedded systems and must be paid enough attention.
A) First, please explain the priority reversal problem.
B) Many RTOS provide priority inheritance policies (Priority Inheritance) and priority ceiling policies (Priority ceilings) to solve the priority reversal problem. Please discuss these two policies.
Reference answer:
1 5
There is a risk, because C = C ++ % 5; this expression has been modified twice for C, the behavior is undefined, and the value of C is undefined.
Int A = 0; // data section
Int B; // data section
Static char C; // BSS
Int main (INT argc, char * argv [])
{
Char d = 4; // Stack
Static short e; // BSS
A ++;
B = 100;
C = (char) ++;
E = (++ d) ++;
Printf ("A = % d, B = % d, c = % D, D = % d, e = % d", a, B, c, d, e );
Return 0;
}
A = 2, B = 100, c = 2, D = 6, E = 5
2 A) ISR cannot return a value;
B) ISR cannot pass parameters;
C) floating points are generally not reentrant;
D) The printf function has re-entry and performance problems.
3 a) using the volatile keyword to define a variable is equivalent to telling the compiler that the value of this variable will change at any time, and each time you use it, you need to go to the memory.
Reread its value and do not optimize it at will.
We recommend that you use the volatile variable:
(1) Hardware registers of parallel Devices
(2) Non-automatic variables (global variables) that will be accessed in an interrupt service subroutine)
(3) variables shared by several tasks in multi-threaded applications
B) In the function body, a variable declared as static remains unchanged when the function is called.
Within the module (but in the external body of the function), a variable declared as static can be accessed by the function used in the module, but cannot be accessed by other functions outside the module.
Access. It is a local global variable.
In a module, a function declared as static can only be called by other functions in this module. That is, this function is restricted in declaring its
Within the local scope of the module.
What is the difference between static global variables and common global variables? STATIC global variables are only made once to prevent being referenced in other file units;
What is the difference between static local variables and common local variables: static local variables are initialized only once, and the next time is based on the previous result value;
What is the difference between a static function and a common function: a static function has only one copy in the memory, and a normal function maintains one copy in each call.
C) a pointer to a constant integer
A constant pointer to an integer
A constant pointer to a constant integer.
4
A) 0x12345678
Little endian big endian is the opposite
High address --> 0x12 low address --> 0x12
0x34 0x34
0x56 0x56
Low address --> 0x78 high address --> 0x78
B) when the parameter is <= 4 ~ R3 transfer,> 4 pass through the stack Mode
C) exception: synchronization with the CPU clock must be considered during generation. In practice, exceptions are also called synchronization interruptions. When the processor executes a wrong command due to a programming error, or a special situation (such as a page missing) occurs during execution, the processor will generate an exception when it must be processed by the kernel.
Interruption refers to an electrical signal generated by external hardware. It enters from the interrupt pin of the CPU and interrupts the current operation of the CPU;
The so-called exception refers to some events that must be handled during software operation. The CPU automatically generates an event to interrupt the current operation and transfer the event to the exception handling process.
Differences between Asynchronization and Synchronization'
5
6. A high-priority task needs to wait for a low-priority task to release resources, while a low-priority task is waiting for a medium-priority task.
Priority Inheritance: inherits the highest priority of a blocked task as its priority. The task exits from the critical section and recovers
Re-initial priority.
Priority ceilings: Specifies the priority ceiling for semaphores that access critical resources.
The Priority Inheritance policy has little impact on the task execution process, because only the critical resources occupied by the high-priority tasks are applied.
This fact raises the priority of low-priority tasks.
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