Jim plans to test out a new idea using a very low-cost wireless station that he can install outside his dorm room window: users can upload or download their MP3-encoded songs from their laptops, anytime, anywhere on campus. However, the cheap wireless technology acquired is half-duplex: all users can either upload or download–never both at once. The following questions investigate your ability to help Jim in particular ways.
(a) (5 Points): Jim intends to test out the basic idea, with just two users, of whom only one can upload or download one song at a time. To impress him, you whip out the following simple semaphore-based synchronization code that only works for two users, along with an explanation of why it works correctly:
(b) (5 Points): Jims next development step requires that multiple users be able to download songs simultaneously, or upload songs simultaneously. So, you produce new semaphore-based code as follows, with a suitable technical explanation of its workings:
(c) (5 Points): While testing out the “simultaneous” strategy, you sadly discover that bandwidth isn’t unlimited. Therefore, you have to limit the number of simultaneous active upload or download users to 100. Your new semaphore-based code follows, with a good explanation of its function:
(d) (5 Points): What synchronization problems remain with your “Step (c)” solution, and how might you solve them?