美文网首页
嵌入式导论练习题6

嵌入式导论练习题6

作者: 泽泽馥泽泽 | 来源:发表于2017-11-09 12:57 被阅读0次

    嵌入式导论实验报告


    Introduction to Embedded Systems

    Exercise 3 Resource sharing

    Ex 3.1

    1.Explain the difference between private, shared and exclusive resources and give an example of problems encountered in exclusive resources.

    Private resources are used exclusively by one process/thread,whereas shared resources can be used by at least two possibly competing process/thread.
    Simultaneous use of a resource by multiple process/threads without further countermeasures,for example,can raise inconsistencies or illegible spending on printer or monitor. Such resources are also called exclusive resources,there really should always just one process/thread exclusively take on it.

    答:私有资源由一个进程/线程独占使用,而共享资源可以由至少两个可能竞争的进程/线程使用。
    例如,在没有采取进一步措施的情况下,通过多个进程/线程同时使用资源可能会引起打印机或显示器上的不一致或不明确。
    这样的资源分配方式也被称为独占资源,实际上应该总是只有一个进程/线程独占。只是由于虚拟化的技术,资源在肉眼不可发现的情况下供各个进程/线程轮流使用。
    

    2.Propose three ways such that the problem occurring in Resource Sharing Problem of mutual exclusion (mutual exclusion) can be solved.

    Non-preemptive tasks,interrupts disabled,static scheduling,Use of semaphores.

    解决方法:非抢先任务,禁用中断,静态调度,使用信号量。
    

    3.Explain the application of a possible solution of the previous part.

    A(binary)semaphore S is a data structure that can be accessed only by the
    atomic commands,wait(s),bzw. P(s) and signals (s), bzw. V(S).

    Assume a process A want to enter critical section,it executes a wait(s) on the semaphore and claims the right to entry into the critical section. If the process hears that the semaphore is free,he enters the critical section and releases the semaphore with signal(s) after he left its critical section. If the call of the semaphore wait(s) is occupied by another process B,A waits until B releases the semaphore.

        (二进制)信号量S是一个数据结构,只能由原子命令P(s)V(s)操作。
    
        假定一个进程A想要进入临界区,它会在信号量上执行一个等待并声明进入临界区的权利。
        如果进程听到信号量是空闲的,他将进入临界区,并在离开临界区后用信号释放信号量。
        如果信号量等待的调用被另一个进程B占用,则A等待B释放信号量。
        
        信号量S是一个整数,S大于等于零是代表可供并发进程使用的资源实体数,当S小于零时则表示正在等待使用临界区的进程数。
        
        信号量操作的PV原语是:
        
        P原语操作的动作是:
        
        (1)S减1;
        
        (2)若S减1后仍大于或等于零,则进程继续执行;
        
        (3)若S减1后小于零,则该进程被阻塞后进入与该信号相对应的队列中,然后转进程调度。
        
        V原语操作的动作是:
        
        (1)S加1;
        
        (2)若相加结果大于零,则进程继续执行;
        
        (3)若相加结果小于或等于零,则从该信号的等待队列中唤醒一等待进程,然后再返回原进程继续执行或转进程调度。
        
        PV操作对于每一个进程来说,都只能进行一次,而且必须成对使用。在PV原语执行期间不允许有中断的发生。
        
        信号量机制分 整型信号量机制、记录型信号量机制、and型信号量机制、信号量集。
        
        整型信号量是一种最简单的信号量,主要用于解决并发程序互斥访问临界资源问题。
    

    Ex 3.2

    4.In the lecture you learned about the Priority Inheritance Protocol (PIP). Does the PIP solve the problem of deadlocks? Give a brief explanation for your response.

    No, the PIP does not prevent deadlocks.

    答:不能,PIP不能防止死锁。
    
    PIP优先级继承协议(Priority Inheritance Protocol,
    PIP)的基本思想是当更高优先级的进程Ji被进程Jk阻塞时,Jk暂时继承Ji的优先级,这将防止中间优先级的进程抢占进程Jk使高优先级进程Ji的阻塞时间延长。
    
    PIP优先级继承协议中的死锁问题:
    
    低优先级作业Jl获取信号量S1进入临界区Z1,在执行过程中高优先级Jh抢占Jl并获取信号量S2进入临界区Z2,在Z2中Jh申请S1被Jl阻塞,Jl继承Jh优先级继续执行Z1,此时Jl需要获取S2,死锁产生。
    

    5.Given are the four tasks J1, J2, J3 and J4. The table below contains
    information on their arrival times, deadlines, their execution time and priorities. The tasks with fixed priorities should be handled by a fixed priority scheduling processor as far as possible within their deadlines.

    The drawings in the last row of the table provide information about the
    sequence of individual tasks. Each task contains one or more critical sections, in which the system accesses the two exclusive resources A and B, respectively. In the drawings, each block has one unit of length and non-critical sections are shaded. The critical sections are marked with the corresponding letters A and B. For example, the seven time units long task J4 contains two critical sections, the five time periods long section A and the three time units long section B. A and B are nested here, i.e. during the periods 3-5 J4 must have access to both resource A and resource B.

    ex3.jpg

    Task:

    Now create a scheduling with the Priority Inheritance Protocol and fill out the chart prepared below. Highlight the critical Portions of the tasks with the letters A and B as specified in the last line of the table . Please also
    characterized p4 which is the active priority of Task J4 in the

    given diagram. Note: Pay close attention to the priorities of the individual
    tasks!

    ex3_1.jpg ex3_1fill.jpg

    6.Are all deadlines satisfied through the application of the PIP? If not, how big is the maximum delay (maximum lateness) in units

    of time?

    No,J2 violated its deadline by two time units.

    答:不满足,J2违反两个时间单位的最后期限。
    
    1. Is there a schedule for the tasks specified J1 to J4 that meets all
      deadlines? What changes should be made to the priority? If there is a correct schedule, please show it in the graph provided below. Otherwise, explain why there can be no correct schedule.

    Yes,there is a flow chart such that all deadlines can be met. However,one have to change the priority of at least one task. If PIP is to meet all
    deadlines,for example,the priority order J4>J1>J2>J3 is a good choice.

    是的,有一个流程图,可以满足所有的最后期限。
    但是,必须改变至少一个任务的优先级。
    如果PIP要满足所有最后期限,例如,优先顺序J4\> J1\> J2\> J3是一个不错的选择。
    
    ex3_2.jpg ex3_2fill.jpg

    相关文章

      网友评论

          本文标题:嵌入式导论练习题6

          本文链接:https://www.haomeiwen.com/subject/wappmxtx.html