Skip to content

Operating system programming concepts, Operating Systems with System Programming (IDATA2305) course, spring 2022.

Notifications You must be signed in to change notification settings

Marko19907/OS-programming-concepts

Repository files navigation

OS Programming Concepts

The repository contains examples of operating system programming concepts, e.g. threading, synchronization, and inter-process communication. Made for the Operating Systems with System Programming (IDATA2305) course, spring 2022.

These projects are mandatory but do not count towards the final grade in the subject.

Java CI with Maven

Contents

  • Write a multithreaded program in Java that calculates the required statistical values from the given list of numbers.
  • Create at least 4 worker threads:
    • Thread to determine the average of the given numbers.
    • Thread to determine the minimum value.
    • Thread to determine the maximum value.
    • Thread to determine the standard deviation.
  • Output the values from the parent thread once the workers have exited.
  • Present a solution to this classic synchronization problem using Java and Java's "Monitor" synchronization mechanism.
    • 5 philosophers are sitting at a round table with a large bowl of spaghetti doing one of three things: eating, thinking, or sleeping.
    • There are 5 chairs, 5 plates, and 5 forks.
    • Philosophers don’t speak with each other.
    • A philosopher must eat with two forks, one for each hand.
    • Each time a philosopher has finished eating, he will drop his forks and start thinking.
    • When a philosopher is done thinking, he will become hungry again.
    • Philosophers can not starve or die in this version of the problem.
  • Create a simple Java application that:
    • Uses a shared buffer of fixed size 5.
    • Has a producer thread that puts 10 data items into the buffer.
    • Has a consumer thread that gets all 10 data items from the buffer.
    • Handle the case of buffer full/empty.
    • Use Java's "Monitor" to synchronize the consumer and producer.
  • The buffer size of 5 makes the buffer to small to fit all 10 data items and the solution must take necessary steps to secure that the producer can not produce more items if the buffer is full. The consumer on the other hand must not try to consume data from the buffer if the buffer is empty.
  • Write a multi-threaded application in Java and use Java's "Monitor" for synchronization.
  • Barber shop has one barber, one barber chair, and 5 chairs for waiting customers.
    • If there are no customers, the barber sleeps in his own chair.
    • When a customer arrives, he has to wake up the barber.
    • If there are many customers and the barber is cutting a customer’s hair, then the remaining customers either wait if there are empty chairs in the waiting room or they leave if no chairs are empty.