首页 > 其他分享 >COMP2006操作系统

COMP2006操作系统

时间:2023-04-30 14:22:15浏览次数:36  
标签:customer 操作系统 COMP2006 queue program time your teller


Operating Systems Semester-1 2023

COMP2006 - Operating Systems
CURTIN UNIVERSITY
School of Electrical Engineering, Computing and Mathematical Sciences
Discipline of Computing
Customer Queue
Due Date: 4.00 pm Monday 8th May 2023
The goal of this assignment is to give experiences in using pthreads, including thread creations,
synchronizations, and using system calls. You are asked to write a program in C in Linux
environment to simulate the operations of a hypothetical customer queue in a bank.
A. Specification
The program for this customer queue simulator includes the following features. Read
completely before writing your program / assignment.
1. There is a First-in First-out (FIFO) customer queue, called c_queue, where customers
queue up waiting for four bank tellers: teller-1, teller-2, teller-3, and teller-4. Assume
that initially the queue is empty, and all the four tellers are waiting for customers. Let m
(in integer) be the size / length of c_queue.
2. When there is no customer in the queue, each teller sleeps / blocks. Arrival of a customer
(to c_queue) will wakeup / un-block one waiting teller, which will call the customer, and
provide required services. Thus, this step simulates the producer consumer problem with
a bounded buffer.
3. Three alternative services are provided by each teller:
Cash-withdraw, which requires tw seconds to service,
Cash-deposit, which requires td seconds to service, and
Ask-information, which requires ti seconds to service.
Assume that all tellers have the same speed for each of the service types.
4. Since a teller needs time to provide service, you must simulate this event. This can be
done, for example, by using a sleep() system call. Note that this assignment does not
require an accurate time measurement.
Operating Systems Semester-1 2023

5. A customer list is stored in a file called c_file. A customer in the file is represented as:
customer# service_type
where the customer# is a positive integer, and the service_type is either W (for
withdrawal), D (for deposit), or I (for a customer that needs information). For example,
c_file may contain the following (customer# and service_type is separated by a space):
Please create your own c_file with a reasonable number of customers, e.g., 100.
6. Each teller k (except the last one) terminates when the queue is empty. However, one of four
tellers, i.e., the last teller, terminates only when there is no longer incoming customer (NOT
when the queue is empty).
7. All activities of the queue and the tellers are recorded in a file named r_log.
B. Implementation
1. Write a function customer() that periodically (every tc seconds) gets a customer from the
c_file and puts the information in c_queue. Create one thread that runs function
customer().
2. After putting a customer in the queue, function customer() writes this activity into file
r_log in the following format:
-----------------------------------------------------------------------
Customer#: service type
Arrival time: 13:42:51
------------------------------------------------------------------------
where customer# is the customer number, service type can be either W, D or I, and the
arrival time is the time when the customer is placed into the queue (actual time). Use a
system call to get the time. Note that this assignment does not require an accurate time.
3. Write a function teller() that simulates the operations of each teller. When there is at least
one customer in the queue, the teller takes one customer from the queue, and serves the
customer. Create four threads for teller-1, teller-2, teller-3, and teller-4, each of which
runs function teller().
Operating Systems Semester-1 2023

4. Use pthread mutual exclusion functions, i.e., pthread_mutex_lock(),
pthread_mutex_unlock(), pthread_cond_wait(), and pthread_cond_signal(), to protect any
shared variables. In your report, you must describe / discuss in detail each shared variable,
including its data structure, the threads that access them, and how mutual exclusion is
achieved. Remember to clean up all resources created in your program.
5. When a teller (for example teller-1) takes one customer (for example customer number 3)
from the queue, the teller writes the following information to file r_log:
Teller: 1
Customer: 3
Arrival time: 13:42:55
Response time: 13:42:57
The response time is the time when the teller picked up the customer from the queue. Note
that this assignment does not require an accurate time.
6. When a teller (for example teller-1) finishes with one customer (for example customer 3),
the teller writes the following information in file r_log:
Teller: 1
Customer: 3
Arrival time: 13:42:55
Completion time: 13:42:57
The completion time is the time when the teller finished servicing the customer. Note that
this assignment does not require an accurate time.
7. On termination, a teller (for example teller-1), writes the following information in file r_log:
Termination: teller-1
#served customers: n1
Start time: 13:42:51
Termination time: 13:42:57
The start time is the time teller-1 is created, the termination time is the time the teller
terminates, and n1 is the total number of customers who have been served by teller-1. Note
that this assignment does not require an accurate time.
Operating Systems Semester-1 2023

8. The last teller that terminates writes the following information:
Teller Statistic
Teller-1 serves n1 customers.
Teller-2 serves n2 customers.
Teller-3 serves n3 customers.
Teller-4 serves n4 customers.
Total number of customers: n customers.
Note:
(i) n1, n2, n3, and n are respectively the number of customers that have been served by
teller-1, teller-2, teller-3, and teller-4, and
(ii) n is the total customers that have been served by the tellers
9. YOU MUST FOLLOW THIS OUTPUT FORMAT.
10. The assignment does not require precision involving the measurement of time.
11. To test for the correctness of your program, you should run the program as follows:
cq m tc tw td ti
where (i) cq is the file name of your executable program, (ii) m is the size / length of
customer queue (c_queue), (iii) tc is the periodic time for the customer to arrive in the
queue, and (iv) tw, td, and ti respectively represent the time duration to serve withdrawal,
deposit, and information. Each variable is a positive integer.
Operating Systems Semester-1 2023

C. Instruction for submission
1. Assignment submission is compulsory. As stated in the unit outline, the penalty for late
submission is calculated as follows:
For assessment items submitted within the first 24 hours after the due date/time,
students will be penalised by a deduction of 5% of the total marks allocated for the
assessment task;
For each additional 24 hour period commenced an additional penalty of 10% of the
total marks allocated for the assessment item will be deducted; and
Assessment items submitted more than 168 hours late (7 calendar days) will receive a
mark of zero.
2. Please read and follow the Academic Integrity (including plagiarism and cheating)
section in the unit outline to prevent any possible academic misconduct.
3. You must (i) submit the soft copy of the report to the unit Blackboard (in one zip file), and
(ii) put your program files, i.e., cq.c, and other files, e.g., makefile, c_file and r_log, in
your home directory named OS/assignment.
4. Your assignment report should include:
A signed Declaration of Originality form (available in the unit Blackboard). Please
read the form carefully before you sign it. Your name should be as recorded in the
student database.
Software solution of your assignment that includes (i) all source code for the programs
with proper in-line and header documentation. Use proper indentation so that your code
can be easily read. Make sure that you use meaningful variable names and delete all
unnecessary comments that you created while debugging your program; and (ii) readme
file that, among others, explains how to compile your program and how to run the
program.
Detailed discussion on how synchronization is achieved when accessing shared
resources / variables and which threads access the shared resources.
Description of any cases for which your program is not working correctly or how you
test your program that make you believe it works perfectly.
Sample inputs and outputs from your running programs. Explain if the outputs are
correct / incorrect.
Your report will be assessed (worth 20% of the overall assignment mark).
5. You are required to demonstrate your working program. The demo time will be announced
later. Your program must run on a computer in our Linux lab, e.g., lab 232 in building 342.
Failure to meet these requirements may result in the assignment not being marked.

 

标签:customer,操作系统,COMP2006,queue,program,time,your,teller
From: https://www.cnblogs.com/mondayw/p/17365227.html

相关文章

  • 关于Linux操作系统OS账号最后一次登录时间的审计
    本文以RedHatEnterpriseLinuxrelease8.1(Ootpa)为例,应该也能适用于7.x版本的如果对操作系统中的账号审计,其中有一个项目可能会比较重要(尤其是对于个人账号),那就是最后一次登录的记录如果需要查看每一个OS账号的最后一次登录记录,可以使用lastlog命令[qq-5201351@localho......
  • 操作系统(3.1)--处理机调度和作业
    一、处理机调度层次1.高级调度(HighLevelScheduling)高级调度又称长程调度或作业调度,它的调度对象是作业。其主要功能是根据某种算法,决定将外存上处于后备队列中的哪几个作业调入内存,为它们创建进程、分配必要的资源,并将它们放入就绪队列。主要用于多道批处理系统中,而在分时和实......
  • 令人感叹的10个非主流操作系统
        这里要谈的操作系统既非Windows,也非MacOSX或Linux,也不是BSD或Solaris,我们要谈的这10个操作系统远没有那么主流。它们一般由一些技术狂人或小公司开发,它们的存在向我们展示了技术的各种可能。AmigaOS4.12008年9月,AmigaOS4.1发布。虽然AmigaOS在操作系统行......
  • 网安等保-国产Linux操作系统银河麒麟KylinOS-V10SP3常规配置、系统优化与安全加固基线
    [点击......
  • 计算机操作系统随笔
    计算机操作系统是一种控制和管理计算机硬件和软件资源的软件程序,类比为一座大厦的物业管理。它负责管理计算机硬件资源,如中央处理器、内存、硬盘等,以及软件资源,如程序、文件等。一座大厦的物业管理主要负责管理大厦的各项资源,如电力、水源、电梯、消防等,确保大厦能够正常运作。......
  • VMware Workstation 安装 Linux操作系统虚拟机详细步骤
    VMwareWorkstation安装Linux操作系统虚拟机详细步骤......
  • SysCare:为您的操作系统保驾护航
    最近,openEuler社区推出了一个创新项目:Linux操作系统统一热补丁服务SysCare。本文将带您探索SysCare的奥秘。认识SysCare「SysCare:Itakecareofyoursystems.」顾名思义,SysCare是一款操作系统运维工具,解决系统运行过程中的各类故障和风险,为Linux操作系统提供全方位......
  • 考研408操作系统-磁盘相关知识点
    一、磁盘的结构二、磁盘调度算法先来先服务算法最短寻找时间优先扫描算法(SCAN)LOOK磁盘调度算法循环扫描算法(C-SCAN)C-LOOK磁盘调度算法三、减少磁盘延迟时间的方法交替编号错位命名四、磁盘的管理五、固态硬盘......
  • 考研408操作系统-缓冲区管理
    缓冲技术分类:单缓冲双缓冲循环缓冲缓冲池一、单缓冲单缓冲是操作系统提供的一种最简单的缓冲形式,当用户进程发出一个IO请求时,操作系统便在内存中为它分配一个缓冲区。由于只设置一个缓冲区,设备和处理器交换数据时,应该先把要交换的数据写入缓冲区,然后放入工作区,在工作区的......
  • linux操作系统分析实验五-深入理解进程切换
    Lab5:深入理解进程切换首先找到对应进程调度的代码文件Kernal/sched/core.c  找到context_switch()函数   其中包括rq,为进程的runningqueue;以及进程切换前后的进程描述符prev和next  首先调用一些函数做上下文切换的准备,与最后出现的finish_task_switch()成......