question for _ENDPOINT_G(e) - Minix

This is a discussion on question for _ENDPOINT_G(e) - Minix ; in include/minix/endpoint.h, there is a line: #define _ENDPOINT_G(e) (((e)+NR_TASKS) / _ENDPOINT_GENERATION_SIZE) I doubt whether "+NR_TASKS" here is necessary ? Because e is generated by, #define _ENDPOINT(g, p) ((g) * _ENDPOINT_GENERATION_SIZE + (p)) Which means _ENDPOINT_G(e) is, (((g) * _ENDPOINT_GENERATION_SIZE + ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: question for _ENDPOINT_G(e)

  1. question for _ENDPOINT_G(e)

    in include/minix/endpoint.h, there is a line:
    #define _ENDPOINT_G(e) (((e)+NR_TASKS) / _ENDPOINT_GENERATION_SIZE)

    I doubt whether "+NR_TASKS" here is necessary ?

    Because e is generated by,
    #define _ENDPOINT(g, p) ((g) * _ENDPOINT_GENERATION_SIZE + (p))

    Which means _ENDPOINT_G(e) is,
    (((g) * _ENDPOINT_GENERATION_SIZE + (p)+NR_TASKS) /
    _ENDPOINT_GENERATION_SIZE)
    equals to,
    (g) + ((p) + NR_TASKS)/_ENDPOINT_GENERATION_SIZE

    Here ((p) + NR_TASKS)/_ENDPOINT_GENERATION_SIZE always is 0.

    So I just doubt whether it's necessary to add NR_TASKS to e to get
    generation number ?

    How about
    #define _ENDPOINT_G(e) ((e) / _ENDPOINT_GENERATION_SIZE) ?

    If there is any mistaken, please tell me.

    Thanks.

    Coly

  2. Re: question for _ENDPOINT_G(e)

    On 1月26日, 下午4时46分, colyli wrote:
    > in include/minix/endpoint.h, there is a line:
    > #define _ENDPOINT_G(e) (((e)+NR_TASKS) / _ENDPOINT_GENERATION_SIZE)
    >
    > I doubt whether "+NR_TASKS" here is necessary ?
    >
    > Because e is generated by,
    > #define _ENDPOINT(g, p) ((g) * _ENDPOINT_GENERATION_SIZE + (p))
    >
    > Which means _ENDPOINT_G(e) is,
    > (((g) * _ENDPOINT_GENERATION_SIZE + (p)+NR_TASKS) /
    > _ENDPOINT_GENERATION_SIZE)
    > equals to,
    > (g) + ((p) + NR_TASKS)/_ENDPOINT_GENERATION_SIZE
    >
    > Here ((p) + NR_TASKS)/_ENDPOINT_GENERATION_SIZE always is 0.
    >
    > So I just doubt whether it's necessary to add NR_TASKS to e to get
    > generation number ?
    >
    > How about
    > #define _ENDPOINT_G(e) ((e) / _ENDPOINT_GENERATION_SIZE) ?


    I understand why adding NR_TASKS, because endpoint number is possible
    to be negative. Therefore, should +NR_TASKS to make sure generation
    number is positive.

    So +NR_TASKS is necessary :-)

    >
    > If there is any mistaken, please tell me.
    >
    > Thanks.
    >
    > Coly



+ Reply to Thread