Assignment 1 - Part 1 Flashcards

1
Q

gfclient_download.c

A

main file for the client workload generator.
Illustrates use of gfclient library, how the API is intended to be used
user code of gfclient. This possible means that it uses the gfclient.c

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

function pointers in C

A

are callbacks

Use cases

  • Function pointer can be used in place of switch case.
  • consider the following C program where wrapper() receives a void fun() as parameter and calls the passed function.
void A()
{
    printf("I am function A\n");
}
void B(void (*ptr)())
{
    (*ptr) (); // callback to A
}
int main()
{
    void (*ptr)() = &A;
    // calling function B and passing
    // address of the function A as argument
    B(ptr);

return 0;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

opaque pointer

A

meaning that it should be defined within the gfclient.c file and no user code (e.g. gfclient_download.c) should ever do anything with the object besides pass it to functions in the gfclient library.

Opaque pointers are a way to hide the implementation details of an interface from ordinary clients, so that the implementation may be changed without the need to recompile the modules using it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

gfc_set_writearg

A

the user can register an argument that should be passed to the callback on every call with this function

Sets the third argument for all calls to the registered write callback

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

gfc_set_headerarg

A

the user can register an argument that should be passed to the callback on every call with this function
Sets the third argument for all calls to the registered header callback
pointer registered with gfc_set_headerarg

How well did you know this?
1
Not at all
2
3
4
5
Perfectly