free_bookz_player
    and have, as a result, written some new requirements. You have been
    hired to implement the changes.
  main() function of the free_bookz_player
    must call the display_all() function in the
    bookz_lib module directly. In other words, the
    bookz must be displayed in the main thread. (As in version 1.)
start_adz() function must be called in a "helper"
    thread. (As in version 1.)
pthread_mutex_t variables
    to coordinate access to the shared variables. (New in version 2.)
pthread_cond_t variables
    to notify threads of state changes. (New in version 2.)
STDOUT_FILENO.
    (As in version 1.)
bookz_lib module may change,
    the bookz_player executable must build and execute
    exactly as it did before the introduction of
    the free_bookz_player.
    bookz
    are displayed in the main thread and the text of the advertisments are
    displayed in the helper thread (and there is no coordination between the
    two).
    
    Hence, in version 2, both the lines of the bookz and
    the text of the advertisments must be displayed in the main thread.
    Specifically, the line of the bookz must be
    displayed, the main thread must sleep for 1 second, and then the
    text of the advertisment must be displayed. Of course, this will
    mean that the display_all() function in
    the bookz_lib module must be modified so that it now calls
    the display_adz() function in
    the adz_lib module.
    
start_adz() function iteratively
    read information from the adz file and called 
    the display_adz() function. Now the
    display_adz() function is called by
    the display_all() function, so the start_adz()
    function must play a different role.
    
    In version 2, the start_adz() function (which still
    executes in the helper thread) must read from the adz
    file and assign values to one or more shared variables that
    the display_adz() function (which executes in the
    main thread) uses.
    
    At a minimum, you must have a shared variable
    (named adz_current_text) that contains the text of
    the advertisment. (Was a variable with file scope in version
    1.)
    You may also want to have a shared variable
    (named adz_updated) that indicates whether or not
    adz_current_text has changed since it was displayed
    and a function named adz_is_updated() that can be
    used to check the value of this variable.  You
    may, instead, want to use a pthread_cond_t variable
    for this purpose.
    
    Of course, you must coordinate access to the shared variable(s) 
    and/or  pthread_cond_t variables using
    one or more pthread_mutex_t variables.
    
bookz_done) that the start_adz()
    function will use (in the helper thread) to determine whether it
    should stop iterating. This variable will be set by the main thread
    (when the bookz is done).
    
    Of course, you must coordinate access to this shared variable
    using one or more pthread_mutex_t variables.
    
bookz_lib module. However, for obvious reasons,
    it is important that the bookz_player continue to
    (build and) execute as it did before. This is best accomplished
    using preprocessor directives. The code (and other preprocessor
    directives) specific to the
    free_bookz_player should be added between 
    #ifdef ADZ and #endif ADZ
    directives. Then, when building the free_bookz_player 
    module, you should define the symbol ADZ (e.g., using the
    -D ADZ option or a #define ADZ directive).   
    In this way, the code that is
    specific to the free_bookz_player will only be included
    in the free_bookz_player.
    
    For example, if you use this design you will want to add a
    function (with external linkage) to
    the adz_lib module that can be called from
    the main() function in the
    free_bookz_player module to set the value of
    bookz_done and you will want to add a function
    that can be called from the start_adz() function
    to get the value of bookz_done so that it knows when
    to stop displaying advertisements.
    
    While this may seem more complicated, the advantage of this design
    is that you can include all of the coordination-related code in
    the adz_lib module.
    
The advantage of this design is that it makes the sharing more apparent. The disadvantage is that the coordination-related code is not centralized.
makefile) needed to build both
  the free_bookz_player
and
  the bookz_player. Unless you have added other modules,
  this means you must submit the bookz_lib module,
  the adz_lib module, the free_bookz_player
  module, and the bookz_player module.
  Copyright 2017