• Create a directory named ``pup8'' under your home directory.
    This directory must contain
    • Makefile
    • README
    • other files ...
  • Objective: simulating printer daemon with FIFOs and threads
  • Due day, 5/20 00:01am
  • Description:
    This exercise inlcudes 3 parts which are commands, daemon, and printers.
    • Commands: Two commands are needed. Their names and usages are as follows: (Your output format of mylpq may be different. It is left to you.)
            $ ./mylpr -d ps1 toc.ps           # submit toc.ps to ps1
            $ ./mylpr -d ps1 part2.ps         # submit part.ps to ps1
            $ ./mylpq -d ps1                  # list the queue for printer "ps1"
                 <1>    toc.ps    printing
                 <2>    part.ps
            $ ./mylpq -l                      # list the available printers
                ps1  hp  line
            $
          
    • daemon: Inside this daemon, there is one thread for receiving and handling the commands and one thread per printer.
    • printer: This program is just a dummy printer. After receiving an request, it just sleeps for a while and acknowledges back to daemon.
    • The request issued by ``mylpr'' or ``mylpq'' is passed to printer daemon through a FIFO. The daemon must echo back an reply or something. You can create another FIFO for such purpose or use the previous FIFO since the FIFO is bidirectional.(CHECK it!)
    • Each printer is also connected to the corresponding thread in daemon through one or one pair of FIFO.
    • What information is passed through the FIFO is left to you.
    • This is just an simulation. The focus is the threads and synchronizing between them. File copying may be omitted.
  • Requirement:
    • Makefile: Typing ``make'' will generate ``mylpr'', ``mylpq'', the daemon program, printer program and the corresponding FIFOs. That is, the default target will bring you ready to run such simulation.
      Also include a ``clean'' target. That is, typing ``make clean'' will clean all the executable and FIFOs. Only the sources are left.
    • README: Please explain how you completes such exercise as detail as possible. For example, what information is passed through the FIFO? Do you use one FIFO or two FIFOs for connection? What name is your printer executable? What name is your dameon?
    • Although ''mylpr'' and ``mylprq'' looks different, you should only create just one executable and using ``ln'' command to create another. That is, your program must check ``argv[0]'' to know what action it is expected.
    • At least 3 printers are required for testing.
  • Bonus: You can also include a command ``mylprm'' to remove an request. Of course, the file in printing can not be cancelled.
          $ ./mylpr -d ps1 toc.ps           # submit toc.ps to ps1
          $ ./mylpr -d ps1 part2.ps         # submit part.ps to ps1
          $ ./mylpq -d ps1                  # list the queue for printer "ps1"
               <1>    toc.ps    printing
               <2>    part.ps
          $ ./mylprm -d ps1 2
             part.ps was cancelled
          $ ./mylpq -d ps1
               <1>    toc.ps    printing
          $