To that end, zmedia has decided to distribute two different products, the existing zplayer (with the advanced user interface) and a stripped-down product called free_bookz_player that just displays a bookz from start to finish (like the original bookz_player), but with periodic brief advertisements.
You must uncompress it (using gzip
) and extract the
collection (using tar
) before using it, but you must not
change any of the individual file names or the contents of the files.
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.
start_adz()
function must be called in a "helper"
thread.
STDOUT_FILENO
.
bookz_lib
, and you
should not need to modify it.
You will not need to use the existing bookz_player
module,
zplayer
module, or the states/statemodel (since the
free_bookz_player
has a very simple user interface).
free_bookz_player
(i.e., in the main thread).
The number of lines can be handled as in PA1. The number of ads
is returned by the start_adz()
function. However, since
start_adz()
runs in the helper thread, it must be
obtained by the free_bookz_player
indirectly.
The variable lines_read
has file scope and external
linkage. As a result it can be (and is) used by multiple functions
and in multiple translation units. However, since it is only used
by the main thread, it is not shared.
You must not use a variable with file scope and/or external linkage to keep track of and display the number of advertisements (since it would be used by both the helper thread and the main thread and, hence, would be shared).
settimer()
] for this system, but you shouldn't do
so. "Interval timers" use signals and, unless they are absolutely
necessary, signals should be avoided in multi-threaded programs
(because all threads share the same signal dispositions). You
should probably use sleep()
instead.
atoi()
) to
convert strings to numbers.
Copyright 2017