Checkout Systems

Published:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

1.0 Introduction

The real time and concurrent system of a supermarket’s checkout counter is vital for saving in cost, checkout speed, efficiency, and effectiveness. Timing and coordination between lines and control system play an important role as it will directly effect the success of multitasking system and achieving error free system.This report discuss the system of a supermarket’s checkout lines to demonstrates multithreading, concurrency, inter-process communications and synchronisation of the process to achieve a real time manner.

This simulator was developed using multi-processes which includes a man process acts as a parent and four child processes which controls the input, display layout, customer generating process, self checkout counter and assisted checkout counter. The inter-processes are communicating using various method of C/C++ mechanism such as data pools and pipelines. The event synchronisation technique and mutual exclusion was used in the display layout, data pool read and write process to ensure all processes run in desire order and the control command. Details of the mentioned techniques above will be explained further more in the discussion section.

1.1 The Simulation Concept

This multi-tasking concurrent simulator will simulates a system which consists of a set of several lines (counter) which is L0 (Customer generating process), L1 (Assisted checkout counter) and L2 (Self checkout counter) as checkout lines in supermarket. A parent process (parent) created all four child processes (IO, L0, L1, L2) processes that running independently with various inter-process connections. The stock item, bread and milk, are transported into L0 and then checkout at L1 and L2 randomly.

The IO process (IO) sends the commands to the child processes after receive the commands key in by the user. Add of this, IO also as a display window for all general information of the whole system. L0 is a process that generates random number of customer to be in queue and wait to soft to L1 or L2. These process is to ensure the efficiency and effectiveness of both checkout counter, if we sorted the customer queue in the checkout counter, when one of the counter occur error the whole line will be suspend and customer will be queue in the down line forever until the checkout line resume the process. L1 and L2 are the processes that generate random number of “milk” and “bread” to be buys by a single customer every time they check out from the supermarket.

Those commands received by IO process will randomly sort into child processes are made up by a two character key sequence. The first key identifies the line number, while the second key is a letter indicating the command.

The commands are outlined below:

W – Increase speed of the line.

Q – Decrease speed of the line.

S – Stop the line.

R – Resume the line.

XX – terminates the system.

The system will run continuously until the user key in the command to control the system.

3.0 Program Description

In this supermarket’s checkout lines simulator is governed by a single parent process which creates 4 child processes which is IO, L0, L1 and L2. Below is the description of the processes:

3.1 Parent

The parent process will create four child processes which are IO process (IO), customer generating process (L0), assisted checkout counter (L1), self checkout counter (L2), a global event and three pipelines which are pipe 3, pipe 4, and pipe 5. The four child processes executed their own process separately. The three pipelines were used to execute the commands from IO process. When IO process receives the second key input is “S” or “s”, the parent will suspend the child processes, while if it receives the second key input is “R” or “r”, then it will perform the resume function to resume the child processes depend on which line to be choose on the first key which is ‘0’, ‘1’ and ‘2’.

Thread was created in parent process and wait for the signal from IO process to execute a quit event. When parent received signal which is the quit event signal that generate from IO process, it will release signal and ask thread to execute quit function.

3.2 IO process

Firstly, the IO process created a global event to execute the quit function for all the processes.

The IO process also created three data pools, which is ‘MyDataPool0’, ‘Product’, and ‘customersdata’ to store and to share the data for other processes to access the information of the line speed, product status, and customer data.

When two processes was acquire the same data pool simultaneously, in order to make sure that is a good real-time system, a function is added to simply wait until all resources requesting are free. Thus, three ‘mutex’ was created for each data pool to avoid deadlock arises, where each process blocks the others.

This process is a user interface, thus an instruction table was created and display in this window. This process will run the while loop wait for user to key in command by testing the input data from keyboard.

Besides, six pipelines were created in this process. Three of them which are pipe0, pipe1 and pipe2 communicate between IO process with three other processes which are L0, L1 and L2. The IO process test the input key from keyboard and send instructions through these pipelines to L0, L1 and L2 processes and execute the increase speed, decrease speed functions. The other three pipelines, pipe3, pipe4 and pipe5 are connected to the parent program the perform stop and resume of the lines.

The global event used in this program is a MULTIPLE_RELEASE to allow all thread which created in other processes to execute a quit event. IO process will generate an event signal when user key in “xx” and send to the thread. Thread will signal the condition if true, then it will execute quit function. At the same time the IO window will print out a message, ‘Emergency stop. System Shut Down In 5 second. Stopping main system....’ to inform the user that system is shutting down.

These are commands outlined as below:

0wincrease speed of line0

0qdecrease speed of line0

0sstop line0

1wincrease speed of line1

1qdecrease speed of line1

1sstop line1

2wincrease speed of line2

2qdecrease speed of line2

2sstop line2

xxshut down the system

If the key in key was invalid then it will show the message ‘Invalid combination’.

Through datapool, This process can grasps the information of total customers has been checked out, customers wait in queue, bread remain in stock, milk remain in stock, total bread sold, total milk sold, bread sold at L1, milk sold at L1, milk sold at L2, bread sold at L2, current speed of L0, current speed of L1, and current speed of L2, display them in window.

This window also displays the line control instruction and allow user to key in command to control the system. This window was created to monitor the supermarket’s stock status, number of item that have been check out, the speed of each line running and the number of customers, so that the efficiency of the system can be optimize.

3.3 Customer Generating Process (L0)

This process will generate random number of customer to purchase the bread and milk. We have set the limit of random number customer, which are minimum one person and maximum five people for every single set of generate random number customer. Once the random number of customers is generated, say 5 customers, they send to an initial queue as a queuing line to be wait for checkout which in the L1 or L2. The 5 customers will be sorted into either one of the checkout lines whenever one of the lines is free to serve the next customer.

There was one data pool used by this process, which is ‘customersdata’. The generated number of customer will be stored into template of data pool called ‘In_Queue’. The customer still in queue will be count by L1 and L2 respectively by every single customer checkout from their counter; they will call the stored data ‘In_Queue’ from the data pool then reduce one customer in queue and update the new data into data pool. These processes will be monitor by a function called ‘Mutex”, to ensure when three processes acquire the data pool, deadlock will not occur or locks by each others.

Pipeline, pipe0 was created to establish a connection between IO process and L0 and receive command from IO process. When the IO process tested input command and detected for:

  • ‘0w’, the instruction will send through pipe0 to L0 to increase the speed of the line by decreasing 0.5 second of the process sleep duration.
  • ‘0q’, the speed will be decreased by increasing 0.5 second of the process sleep duration.

Where initial sleep time was been set at the beginning of this process.

A thread that perform the quit function of the system is created to be waited the signal send by IO process through pipe0. Once the IO process detected the signal is true, it will execute the quit event for shutting down the process in 4 seconds.

This window will display the number of ‘Customer come in’ the supermarket and the number of ‘Customer in queue’ where two of customers is checking out at both checkout counter.

3.4 Assisted Checkout Counter (L1)

First, this process will create one event, two mutex, three data pool, and one pipe line which will be used in following step. The initial value of ‘int sleep’ was set to two second for used in the function of controlling the speed of the line.

Three data pool were used by this process, which are ‘MyDataPool0’, ‘Product’, and ‘customersdata’ to store and to update the data for other process to access it about the information of the line speed, product status, and customer data.

This process will run the while loop function first and testing the number of customer in queue by accessing data pool, ‘customersdata’. When total number of customer in queue is less than or equal to one, this counter will sleep for three second before running the rest of the process. This action is to avoid negative value of customer in queue.

After executed function above, it will generate the random number for how many bread and milk that buy by every single customer when they checkout at Assisted checkout counter. The generated random number of breads and milks will be stored into template of ‘Product’ called ‘B_out1’ and ‘M_out1’. These data will then used for calculate the total stock of both items in the supermarket, and value of the remaining stock will stored in ‘Bread’ and ‘Milk’.

This process also acquire the value of ‘In_Queue’ and reduce 1 every time a single customer checkout from this line, this is because every single customer checkout from the line which mean that number of customer waiting in queue is less 1 person. After update the new value of ‘In_Queue’, it will store the new value into the data pool.

To avoid conflict when accessing the same data pool with other process, ‘Mutex’ was applying for the process.

Pipeline, pipe1 was used to establish a connection between IO process and L1 and receive command from IO process. When the IO process tested input command and detected for:

  • ‘1w’, the instruction will send through pipe0 to L1 to increase the speed of the line by decreasing 0.5 second of the process sleep duration.
  • ‘1q’, the speed will be decreased by increasing 0.5 second of the process sleep duration.

A thread that perform the quit function of the system is created to be waited the signal send by IO process through pipe1. Once the IO process detected the signal is true, it will execute the quit event for shutting down the process in 4 seconds.

This window will display the message ‘Serving 1 cusomer in line....’, total number of milk in stock, total number of bread in stock, number of milk and bread was sold at assisted checkout counter.

3.5 Self Checkout Counter (L2)

In this part, the process will create one event, two mutex, three data pool, and one pipeline which will be used in following step. The initial value of ‘int sleep’ was set to two second for used in the function of controlling the speed of the line.

Three data pool were used by this process, which are ‘MyDataPool0’, ‘Product’, and ‘customersdata’ to store and to update the data for other process to access it about the information of the line speed, product status, and customer data.

This process will run the while loop function first and testing the number of customer in queue by accessing data pool, ‘customersdata’. When total number of customer in queue is less than or equal to one, this counter will sleep for three second before running the rest of the process. This action is to avoid negative value of customer in queue.

After executed above function, it will generate the random number for how many bread and milk that buy by every single customer when they checkout at Self checkout counter. The generated random number of breads and milks will be stored into template of ‘Product’ called ‘B_out2’ and ‘M_out2’. These data will then used for calculate the total stock of both items in the supermarket, and value of the remaining stock will stored in ‘Bread’ and ‘Milk’.

Another template from data pool ‘Product’, called ‘TB’ and ‘TM’ was acquired by this process as well. ‘TB’ and ‘TM’ is the total bread and total milk sell at L1 and L2, these data was update by just simply acquire the data from ‘Product’ and add in number of bread and number of milk sold at L1 and L2.

This process also acquire the value of ‘In_Queue’ and reduce it by 1 every time a single customer checkout from this line, this is because every single customer checkout from the line which mean that number of customer waiting in queue is less 1 person. After update the new value of ‘In_Queue’, it will store the new value into the data pool.

To avoid conflict when accessing the same data pool with other process, ‘Mutex’ was applying for this process.

Pipeline, pipe2 was used to establish a connection between IO process and L2 and receive command from IO process. When the IO process tested input command and detected for:

  • ‘2w’, the instruction will send through pipe2 to L2 to increase the speed of the line by decreasing 0.5 second of the process sleep duration.
  • ‘2q’, the speed will be decreased by increasing 0.5 second of the process sleep duration.

Where initial sleep time was been set at the beginning of this process.

A thread that perform the quit function of the system is created to be waited the signal send by IO process through pipe2. Once the IO process detected the signal is true, it will execute the quit event for shutting down the process in 4 seconds.

This window will display the message ‘Serving 1 customer in line....’, total number of milk in stock, total number of bread in stock, number of milk and bread was sold at self checkout counter.

4.0 Discussions

4.1 Data pools expanding

Initially, the program was planned to have a single data pool to store all the data from all four child processes as mentioned above. As a result, the memory was full and the value that obtained is 0. Therefore, three data pools have to be used as the assignment instructed.

4.2 Problem with synchronizing between processes

The semaphore function was used to implement the synchronization between processes. But it cannot work properly as the data was lost during executing the processes. This was causing the customer generate process lost their data during execution. This because the bad practise of synchronizing between the processes will lead to a huge error.

To overcome this problem, the Mutex is used because it has the same function just like semaphore. Turn out the result was running finely.

4.3 Problem with terminating the processes

By using the pipeline to communicate between processes, other process cannot read the command ‘xx’ from the IO process. It would not shut down the processes after pressing ‘xx’. To overcome this problem, a global event is created which execute quit function in all processes by using a thread.

5.0 Recommendations

5.1 Providing more item variations

In real life time, a supermarket does not sell only bread and milk. It has lots variation of product. Even so, the program that is written is expandable to more items requirement of the user. To simulate more variation of items, the programmer could add more instruction line which produces the random number for another item.

5.2 Expandable checkout lines

This can be done by creating more process to represent more checkout lines. It will require more data pools as well for the process to update the data from the checkout lines. Thus, programmer needs to create an additional pipeline and sub process to simulate the control system.

5.3 Add in timer

Through additional timer, user can know the actual working time of check out line and monitor it. The effectiveness of the checkout line also can be maintain simultaneously and improve their system if necessary.

6.0 Conclusions

As a conclusion, the simulation of supermarket’s checkout counters is able to run in a real time and concurrent manner with every process is fully functional and it has fulfilled the basic requirement. Even though the program runs in a steady and fine condition, it still has some minor sections which can be improved. This program is recommended to run in multiprocessors computer to achieve its accuracy and concurrency.

7.0 References

 

[1] Arul Selvan. Real-time and Concurrent Systems - Lecture Notes. 2008.

[2] www.cplusplus.com

Writing Services

Essay Writing
Service

Find out how the very best essay writing service can help you accomplish more and achieve higher marks today.

Assignment Writing Service

From complicated assignments to tricky tasks, our experts can tackle virtually any question thrown at them.

Dissertation Writing Service

A dissertation (also known as a thesis or research project) is probably the most important piece of work for any student! From full dissertations to individual chapters, we’re on hand to support you.

Coursework Writing Service

Our expert qualified writers can help you get your coursework right first time, every time.

Dissertation Proposal Service

The first step to completing a dissertation is to create a proposal that talks about what you wish to do. Our experts can design suitable methodologies - perfect to help you get started with a dissertation.

Report Writing
Service

Reports for any audience. Perfectly structured, professionally written, and tailored to suit your exact requirements.

Essay Skeleton Answer Service

If you’re just looking for some help to get started on an essay, our outline service provides you with a perfect essay plan.

Marking & Proofreading Service

Not sure if your work is hitting the mark? Struggling to get feedback from your lecturer? Our premium marking service was created just for you - get the feedback you deserve now.

Exam Revision
Service

Exams can be one of the most stressful experiences you’ll ever have! Revision is key, and we’re here to help. With custom created revision notes and exam answers, you’ll never feel underprepared again.