Some assitance please

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • albert_reade@yahoo.com

    #1

    Some assitance please

    Hello I was wondering if someone could please help me understand what I
    need to do in order to get this project to work. I just need some hints
    or a push in the right direction to get this to work, thanks.

    Design the Array of Expected Events, AEE, required by the interrupt
    system. Each entry
    i, 0 <= i < 6, in this array contains three fields, AEE[i].IIC,
    AEE[i].InterruptHandl er,
    AEE[i].WaitingQueue. These elds are designed such that they can
    accommodate the
    following information:

    a. AEE[i].IIC is used to identify the interrupt identification code of
    the interrupt agents
    that belong to the level i of interrupts. For this project the
    interrupt identification
    codes will be defined by a range of integers. This range of integers is
    stored in
    the AEE[i].IIC as an interval (i1; i2) where i1; i2 are positive
    integers, i1 < i2. For
    example, a potential situation could be: AEE[0].IIC = (0,20),
    AEE[1].IIC = (21,23),
    AEE[2].IIC = (24,34), AEE[3].IIC = (35,40), AEE[4].IIC = (40,44),
    AEE[5].IIC =
    (45,59). Assume that an interrupt at the level 0 having the interrupt
    identification
    code 10 would occur. Since 0 <= 10 <= 20, this agent is valid and would
    activate the
    Device Interrupt Handler AEE[0].InterruptHandl er which in turn would
    print:

    Interrupt Level: 0
    Agent interrupting at level 0: 10
    Prime numbers generated: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29

    Note that you must choose interrupt identification codes integers in
    the ranges from
    the range 0-59. However, all identification code ranges must be
    disjoint.

    b. AEE[i].InterruptHandl er is the address of the "InterruptHandl er".
    This field will be
    implemented as a pointer to a C-function (returning type integer). An
    appropriate
    declaration of this field might be:

    c. AEE[i].WaitingQueue is a FIFO queue that stores processes waiting
    interrupts on
    this level to arrive. Since processes that issue system calls generate
    exceptions,
    that is, they suspend themselves for an event, the AEE[5].WaitingQueue
    is null.
    However, these processes are identified by their agent number in the
    integer interval
    specified in AEE[5].IIC. When a process suspends itself by a system
    call it is sent
    in the queue of processes waiting for some other event to occur. That
    is, the events
    for which processes suspend themselves are the occurrences of other
    interrupts.

    In order to simulate the handling of the FIFO queues organized in
    AEE[0].WaitingQueue,
    AEE[1].WaitingQueue, AEE[2].WaitingQueue, AEE[3].WaitingQueue,
    AEE[4].WaitingQueue,
    when a system call interrupt occurs the process is sent in the waiting
    queue AEE[AgentNumber
    % 5].WaitingQueue where % is the modulo-operator in the C language.
    This means
    that interrupt handler for the system call in addition to the printing
    of its number
    and prime numbers as specified above will perform an operation
    enqueue(ProcId,
    AEE[AgentNumber % 5].WaitingQueue). The interrupt handler treating
    inter-
    rupts that arrive on the interrupt levels i, 0 <= i <= 4, will remove
    processes from
    their own interrupt waiting queues and will show that by printing:

    Interrupt Level: i
    Agent interrupting al level i: j
    No processes is waiting in the AEE[i]. WaitingQueue

    if their queues are empty, or

    Interrupt Level: i
    Agent interrupting al level i: j
    Process ProcId was freed from the queue AEE[i].WaitingQueue

    if the process "ProcId" is the first process waiting in that queue.

    this is what I have started with

    #include <stdio.h>
    #define Size 6

    typedef int (* InterruptHandle r)();

    struct AEEEntry
    {
    int IIC;
    InterruptHander IHA;
    struct WaitingQueue *PWQ
    }AEE[Size];

  • Michael Mair

    #2
    Re: Some assitance please

    albert_reade@ya hoo.com schrieb:[color=blue]
    > Hello I was wondering if someone could please help me understand what I
    > need to do in order to get this project to work. I just need some hints
    > or a push in the right direction to get this to work, thanks.[/color]

    Your request looks like a homework question; have a look at
    <http://www.clc-wiki.net/wiki/Introduction_to _comp.lang.c>
    especially 2.1 and 2.2
    [color=blue]
    >
    > Design the Array of Expected Events, AEE, required by the interrupt
    > system. Each entry
    > i, 0 <= i < 6, in this array contains three fields, AEE[i].IIC,
    > AEE[i].InterruptHandl er,
    > AEE[i].WaitingQueue. These elds are designed such that they can
    > accommodate the following information:[/color]

    Translated to C, this means you want AEE to be an
    "array 6 of sometype" where sometype is a structure with exactly
    three members, IIC, InterruptHandle r, and WaitingQueue.
    You _can_ do all of this with one declaration,
    struct {
    ....
    } AEE[6];
    but it usually is a better idea to procede systematically.

    #define AEE_SIZE 6
    typedef struct {
    ....
    } TExpectedEvent;

    TExpectedEvent AEE[AEE_SIZE];

    As soon as we know more about the members, we can fill the structure.[color=blue]
    >
    > a. AEE[i].IIC is used to identify the interrupt identification code of
    > the interrupt agents
    > that belong to the level i of interrupts. For this project the
    > interrupt identification
    > codes will be defined by a range of integers. This range of integers is
    > stored in
    > the AEE[i].IIC as an interval (i1; i2) where i1; i2 are positive
    > integers, i1 < i2. For
    > example, a potential situation could be: AEE[0].IIC = (0,20),
    > AEE[1].IIC = (21,23),
    > AEE[2].IIC = (24,34), AEE[3].IIC = (35,40), AEE[4].IIC = (40,44),
    > AEE[5].IIC =
    > (45,59). Assume that an interrupt at the level 0 having the interrupt
    > identification
    > code 10 would occur. Since 0 <= 10 <= 20, this agent is valid and would
    > activate the
    > Device Interrupt Handler AEE[0].InterruptHandl er which in turn would
    > print:
    >
    > Interrupt Level: 0
    > Agent interrupting at level 0: 10
    > Prime numbers generated: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29
    >
    > Note that you must choose interrupt identification codes integers in
    > the ranges from
    > the range 0-59. However, all identification code ranges must be
    > disjoint.[/color]

    Okay, so we need to represent unsigned integers in the range from 0
    through 59. Nothing is said about how the interval is to be represented,
    so we have some leeway there.
    As we are at it with the structures, let us use one
    typedef struct {
    TIicBound Lower;
    TIicBound Upper;
    } TIicInterval;
    We are still free to choose what type we do want to use.
    For the time being, let us stick with an unsigned type, say
    unsigned short or unsigned char.
    typedef unsigned short TIicBound;

    For extra brownie points, give the user access macros -- if
    the user sticks to them, you can change the member names or
    even the type of TIicInterval (e.g. to an array 2 of TIicBound)

    #define GET_IIC_LOWER(i ic) ((iic).Lower)
    #define SET_IIC_LOWER(i ic, l) ....
    and so on.

    This gives us the struct member IIC as
    TIicInterval IIC;
    [color=blue]
    > b. AEE[i].InterruptHandl er is the address of the "InterruptHandl er".
    > This field will be
    > implemented as a pointer to a C-function (returning type integer). An
    > appropriate
    > declaration of this field might be:[/color]

    Unfortunately, you omitted this information.
    Note that "pointer to a function returning int" is not a really
    sufficient type description. Without the list of parameter types
    for such a function, you effectively deny yourself the benefits
    of type checking.
    Without clarification, the above description is useless.
    Note: Declaring a function pointer type for functions returning
    double and receiving no arguments, looks like this:
    typedef double (*TFcnPtr)(void );
    [color=blue]
    > c. AEE[i].WaitingQueue is a FIFO queue that stores processes waiting
    > interrupts on
    > this level to arrive. Since processes that issue system calls generate
    > exceptions,
    > that is, they suspend themselves for an event, the AEE[5].WaitingQueue
    > is null.
    > However, these processes are identified by their agent number in the
    > integer interval
    > specified in AEE[5].IIC. When a process suspends itself by a system
    > call it is sent
    > in the queue of processes waiting for some other event to occur. That
    > is, the events
    > for which processes suspend themselves are the occurrences of other
    > interrupts.
    >
    > In order to simulate the handling of the FIFO queues organized in
    > AEE[0].WaitingQueue,
    > AEE[1].WaitingQueue, AEE[2].WaitingQueue, AEE[3].WaitingQueue,
    > AEE[4].WaitingQueue,
    > when a system call interrupt occurs the process is sent in the waiting
    > queue AEE[AgentNumber
    > % 5].WaitingQueue where % is the modulo-operator in the C language.
    > This means
    > that interrupt handler for the system call in addition to the printing
    > of its number
    > and prime numbers as specified above will perform an operation
    > enqueue(ProcId,
    > AEE[AgentNumber % 5].WaitingQueue). The interrupt handler treating
    > inter-
    > rupts that arrive on the interrupt levels i, 0 <= i <= 4, will remove
    > processes from
    > their own interrupt waiting queues and will show that by printing:
    >
    > Interrupt Level: i
    > Agent interrupting al level i: j
    > No processes is waiting in the AEE[i]. WaitingQueue
    >
    > if their queues are empty, or
    >
    > Interrupt Level: i
    > Agent interrupting al level i: j
    > Process ProcId was freed from the queue AEE[i].WaitingQueue
    >
    > if the process "ProcId" is the first process waiting in that queue.
    >
    > this is what I have started with
    >
    > #include <stdio.h>
    > #define Size 6
    >
    > typedef int (* InterruptHandle r)();[/color]

    See my comments above.
    This can be nasty if you have functions with prototypes in scope.
    [color=blue]
    >
    > struct AEEEntry
    > {
    > int IIC;
    > InterruptHander IHA;[/color]

    Please post actual code; this won't compile.
    [color=blue]
    > struct WaitingQueue *PWQ
    > }AEE[Size];
    >[/color]

    Well, I think I gave you enough help to get you started.


    Cheers
    Michael
    --
    E-Mail: Mine is an /at/ gmx /dot/ de address.

    Comment

    Working...