Skip to content

radinshayanfar/os-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Operating Systems Lab.

AUT Operating Systems Lab. course (Fall 2020) resources.

All codes are written in C and tested on Linux kernel version 5.

Table of Contents

  1. Introduction to Linux
  2. Kernel module programming
  3. Bash scripting
  4. IPC (Inter-Process Communication):
    1. Shared memory
    2. Simple terminal-based chat application using Socket
  5. Threads and processes: Distributing computation on multiple processes (and probably multiple cores)
  6. Process Synchronization (using Pthread mutex locks for synchronization):
    1. The First Readers-Writers Problem (using fork() and shared memory)
    2. The Dining-Philosophers Problem (using Pthread threads)
  7. Deadlock: Bankers algorithm

Supports up to MAXGROUP groups. Each client should join a group with /join command before sending any messages in the group.

To run the program, compile codes with make all and then execute the server code and arbitrary number of clients.

./server.out <port>
./client.out <server-address> <port> <client-name>

Supported commands (<group-id>s are numbers between [0, MAXGROUP) interval):

/join <group-id>
/send <group-id> <message>
/leave <group-id>
/quit <group-id>

To run the program, execute make run_reader_writer. It'll be creating 1 instance of writer and READERS number of reader(s). The writer increments count variable by one on each iteration up to COUNT_MAX times.

To run the program, execute make run_dining_philosophers. It'll be creating 5 instances of philosophers, each one tries to eat EAT_TIMES times.

Compile the program with make banker and run it using ./banker.out. Configure the number of resources and customers by changing NUMBER_OF_RESOURCES and NUMBER_OF_CUSTOMERS definitions. Each customer runs for MAX_CUSTOMER_ITERATION iterations and requests resources randomly on each iteration from the banker. The banker then decides whether to accept the request or rejecting it (to keep the system in a safe state).

The program reads Available matrix from positional arguments and Max matrix from MAX_FILE_NAME file. For instance, the following line initializes code with Available matrix = [5 6 6 5 5].

./banker.out 5 6 6 5 5

Full description

Read the full description (in Persian) here.