the-krisney-way

Find my designs on awesome products by clicking here!

iTimeOut: NEW GAME!

Play Now by clicking here!

30 Days of Disney Jobseeking Advice

When jobseeking seems a little too boring. (April 2021)

The SLA Experience

Upcoming: A day in the life of an SLA.

It's a Kristen thing...

You probably wouldn't understand. :)

Sunday, January 17, 2021

Research Paper: Erlang In The Clouds

Erlang In The Clouds

Journal paper, BSc Computer Science 2nd Year assignment, 2018.


Abstract


Two kids have access to a shared toy. If both the kids try and play with it, at the same time, the toy may end up breaking. This would be because, the kids are concurrently trying to access the toy, and one is interfering with the other. The solution would be to have the kids play with the toy, one after the other. 

In this paper, we consider the concurrency issues with cloud services. More specifically, we will look at Dropbox. We will also discuss the concurrent execution and interleaving of processes as the processes interact, and how Erlang can be used to implement this scenario and help find a solution to this problem. We will investigate a potential solution, mutual exclusion (Mutex), and how it works in Erlang.

Keywords—concurrency, Erlang, Dropbox, interference, Mutex, semaphore, Cloud

Introduction and Overview


If you have access to more than one device, like a smartphone and a PC, then you would know the troubles of when you have to share files across them. There is a solution to this - ‘Cloud Computing’, also known as ‘The Cloud’. The user’s information and files are stored on servers, and any device that’s connected to the internet can access these files. “You can't see the cloud in the sky, but it's definitely got a silver lining [1].”

The cloud is also widely used in the business environment, where employees may share and work on the same files. It lets you upload files onto the server and lets any device you want synchronize with it, to access any of those files. 

File synchronization is the process of ensuring that any computer files or resources in two or more areas, are updated based on certain guidelines. Services like Dropbox, Google Drive and OneDrive are examples of file sync services and are becoming a necessity, be it for businesses, schools or personal
use. Hundreds of millions of people entrust their data to these services every day [2].

The problem occurs when we must allow more than one person to edit the files at the same time. In this paper, we will discuss this problem - how the concurrent use of a shared resource, could be a source of indeterminate results and could result in interference and issues such as deadlock and starvation of the resource.

Erlang is a concurrent programming language – this means that any parallel processes can be programmed directly in Erlang [3], which would assist in the problem of having two users access a single file, to read and write. And because Erlang is a single assignment language, i.e. variables are immutable, they don’t need concurrency protection [4]. 

In this paper, I will first provide a brief introduction to Erlang and its concepts, terms and the functions involved in multiprocessing (Section II). Then, there will be a detailed description of the problem with concurrency and Dropbox, which will include formal descriptions and presentations of the scenario (Section III). 

A possible approach to the scenario and a solution to the problem, mutex, will be described in detail, also giving formal representations of the machine (Section IV). This will be followed by a short discussion of the advantages and disadvantages of Mutex (Section V). A brief conclusion on mutex will be given (Section VI).

Background


In this section, I will briefly describe the various terminologies and functions that are used in the rest of this paper, along with a brief introduction in the Erlang concepts. 

A. Concurrency And Interference 
Concurrency, in this context, is the ability of having two or more processes running at the same time. This concept may be similar to parallel processing, but with concurrent programming, there is the opportunity of having numerous independent jobs doing different tasks at once, rather than executing an identical job [5]. 

The whole point of concurrent programming is dealing with the interference between threads or processes. If processes access a shared resource, sometimes the result state or output of the shared resource can become incorrect due to a destructive update, caused by the arbitrary interleaving of actions. This is known as interference [6].

B. Erlang And Concurrency
Erlang is a parallel programming language. To control a set of parallel activities, Erlang has primitives for multiprocessing:
‘spawn’ starts the execution of a parallel process, ‘send’ sends a message to a process and ‘receive’ receives a message from a process [3].
spawn/3 starts the execution of a parallel process with the name of the module, the behavior and the arguments of the behavior, and return the process identifier of the process. For example, spawn(dropbox, client, [“”]) causes dropbox:client(“”) to be executed in parallel.

The syntax Pid ! Message is used to send a message. Pid (Process identifier) should evaluate to a process identifier and Message is the message which is to be sent to the process. All arguments are evaluated before sending. 

receive has the following syntax:
receive
Msg1 -> ... ;
Msg2 -> ... ; ...
end.

Each of the processes have a mailbox. When a process receives multiple messages, they are stored in the order they are received, and actions are evaluated in the order they are programmed. Once the action of a message is evaluated, the message is removed from the process’s mailbox. Any message that is not matched, will remain in the mailbox.

register/2, register(name, Pid) associates the name, of type atom, with the Pid. “name” can then be used instead of the Pid, after this function has been run.

For the Dropbox application, the function server/1 acts as a server on which the file would be stored. That is the file onto which we will write and read from. There are three other
functions we will look at:

read/0 takes in no arguments and returns the contents of the file.

write/1 takes in a string and writes it to the file. It returns a tuple with an atom ‘write’ and the string.

4> dropbox:write(“er”).
{write, “er”}
5> dropbox:write(“lang”).
{write, “lang”}

write/1 overwrites the empty string it starts with every time you
use dropbox:write(Str).

6> dropbox:read().
“lang”

upload/1 takes in a string and adds it to the file. It reads what the file already has stored in it and assigns it to the variable OldFile. The string which is input is added to OldFile and the new string is assigned to the variable NewFile. It then writes NewFile onto the server.

4> dropbox:upload(“er”).
{write, “er”}
5> dropbox:upload(“lang”).
{write, “erlang”}

This is a basic Dropbox program wherein a single user can read and write from a file.

UPLOAD = (write -> read -> UPLOAD).




Problem Description


The problem arises when there is more than one person accessing the same file (in this case, trying to access the server). If multiple people have access to the same file, it can cause an overlapping and interference, which can cause indeterminacy of the output.

When you spawn two processes at the same time, the two processes start interfering with each other and give a different output from the expected output. 
DROPBOX = CLIENT_A || CLIENT_B



Above is an FSM that presents all possible traces, including the successful traces. The incorrect outputs we get are because the first process interferes with the second, and the trace of the machine could be as follows:

read.A->read.B->write.A->write.B

read.B->read.A->write.A->write.B

Client A reads an empty file. Client B then reads the file (It is still empty). Client A then writes “er” to the empty file it has read. Client B writes “lang” to the empty file it had read before. These actions interfere and so Client A has been overwritten. Other possible traces, where Client A overwrites Client B, include:

read.A->read.B->write.B->write.A

read.B->read.A->write.B->write.A

One process starts a little after the other, so the screen will display the output of the last process to finish. Actions cannot really happen in parallel. They are processed in sequential parallelism.


Possible Approach (Mutex)


One of the possible solutions to fixing this concurrency issue, as described in Section III, is mutual exclusion. Mutual exclusion, or Mutex, is a process that serializes access.

For example, if DROPBOX = CLIENT || MUTEX, the FSM below describes the following. 




A mutual exclusion (mutex) is a program that, when executed, averts concurrent access to a common resource. Only a single thread can own the mutex at a time, so when the program starts, a mutex is created. When a thread holds a resource, it must lock the mutex from any other threads to prevent concurrent access of the resource (to prevent starvation of data). On giving a signal to the resource, the thread unlocks the mutex and the resource is free for other threads to access [7].




Once the first client accesses the file, the mutex will move from the state FREE to BUSY, using the action ‘wait’. After the client is done with the file, it sends the ‘signal’ to unlock the
mutex and return it back to FREE.

read.A-> write.A->read.B->write.B

This way, there is no interference since client A reads and then writes in sequence before moving onto the next client.

DROPBOX_SAFE = CLIENT_A || CLIENT_B || MUTEX




Discussion


A mutex is a locking mechanism used to coordinate access to a common resource. Only one task can attain the mutex at a time. It means there is ownership linked with mutex, and only the owner of the task can release the lock, as explained in Section IV.

A semaphore is more of a signaling mechanism (“I’m finished with the resource. You may move on”). For example, if you are listening to songs (this could be one task) on your mobile and at the same time, a friend calls you (a second task), it triggers an interrupt, which signals the call processing task to wake up [8].

In this paper, the problem was overcome using a Mutex semaphore. The Mutex would be locked only as far as the client is not finished with the resource. Once the client is finished,
they will send a signal to the Mutex to unlock the resource for the next client to use.

One of the issues with Mutex is that if a thread acquires a lock and goes to sleep, the other thread, that is waiting in the queue, may never be able to move forward. It may lead to starvation.

If Client A locks the file and then Client B requests to use the file, Client B would be added to a queue in order to use the file next. If Client A requests for the file again, they will be added to the queue and thus, creating a deadlock state in which no one can work on the file until the other is finished.

However, it is very easy to implement Mutex and since only one thread is working at any given time, the data remains consistent [9].


Conclusion


This paper has introduced the concept of concurrency and Mutex and provides the example of two users who are trying to edit a shared file on Dropbox concurrently. The problem of interference due to concurrency was put forward (and also, graphically represented) and solved by using the Mutex semaphore.

But Dropbox isn’t the only system that faces the concurrency issue. Through the analysis of this scenario, this solution can be implemented for potentially any system, and possibly modified, if necessary.

Therefore, it is very necessary to implement and experiment with mutual exclusion. Mutex may have its drawbacks, but it could prevent the loss of data, especially if that data is important.

References


[1] “BBC - WebWise - What is cloud computing?”, Bbc.co.uk, 2012. [Online]. Available: http://www.bbc.co.uk/webwise/guides/what-is-cloud-computing. [Accessed: 29- Jan- 2018].

[2] “Lambda Days 2016”, Lambdadays.org, 2018. [Online]. Available: http://www.lambdadays.org/lambdadays2016/john-hughes. [Accessed: 28- Jan- 2018].

[3] J. Armstrong, Programming in Erlang, 2nd ed. Prentice Hall, 2013.

[4] S. Vinoski, Concurrency with Erlang. IEEE Computer Society, 2007.

[5] "What is Concurrency? - Definition from Techopedia", Techopedia.com, 2018. [Online]. Available: https://www.techopedia.com/definition/25146/concurrency-programming. [Accessed: 17- Feb- 2018].

[6] R. Hall, Concurrent Programming. Dr. Richard S. Hall, 2001, p. 8.

[7] “What is Mutual Exclusion (Mutex)? - Definition from Techopedia”, Techopedia.com, 2018. [Online]. Available: https://www.techopedia.com/definition/25629/mutual-ex`clusion-mutex. [Accessed: 30- Jan- 2018].

[8] V. →, “Mutex vs Semaphore - GeeksforGeeks”, GeeksforGeeks, 2013. [Online]. Available: https://www.geeksforgeeks.org/mutex-vs-semaphore/. [Accessed: 14- Feb- 2018].

[9] "2 Advantages of mutex Easy to implement Mutexes are just simple locks that a", Coursehero.com, 2016. [Online]. Available: https://www.coursehero.com/file/p58v9u/2-Advantages-of-mutex-Easy-toimplement-Mutexes-are-just-simple-locks-that-a/. [Accessed: 17- Feb- 2018].

Friday, January 8, 2021

Research Presentation: Inside The Car

Inside The Car

Mini research presentation, MSc Creative Technology, 2019.


Evolution Of The Automobile


Think about the very first car. What do you see? Sticks and stones? Something straight out of the Flinstones? That's what I pictured too. You'd be surprised to know that the very first automobiles ran on steam and electricity. Shocking, right?

Features like speedometers, seatbelts, windshields, and rearview mirrors weren't even in the picture until 1930. Then came turn signals, air-conditioning, and cruise control. The so-called fancy cars of the time. 

Developments in technology are far from overlooked in the automobile industry. There was a time when driverless cars were nothing but science fiction, and we're well on our way to flying cars, let alone driverless.

What's In The Works?


Lots of cars now come with keyless entry, where you don’t even have to get the keys out of your pocket to open it. But what about taking it one step further and not having a physical key at all. Sounds weird? ‘Digital keys’ are the way forward – all you’d need is your smartphone and an app. 

 
Keyless car entry (left); connected to the car (right)

Disbelief aside, it does have very practical uses, such as if you hire a rental car. They’d be no more queuing at the hire desk, you’d just go straight to the car’s location, unlock and go.

i-Cars


Cars don’t just go places these days – they’re connected. That means that wherever you go, you’re online with access to the internet, as some cars automatically connect to local Wi-Fi networks.

Some of the biggest advancements in the world of driving tech have come in the form of safety features, which is great because 95% of all road accidents involve human error.

Safety systems

Passive information systems cover things that most of us would be familiar with, such as sat navs, night vision, and blind-spot detection.

Autonomous driver assistance

Semi-autonomous driver assistance includes features like parking assist or emergency brake assist. Both these features need driver input, but they can also be disabled. Autonomous vehicle control and safety systems are non-compromising features aimed at avoiding or minimizing accidents and, include systems like autonomous emergency braking (AEB).

Eyes On The Road, Buddy


Heads-up display in cars

A lot of creature comforts are closely linked to safety and minimizing driver distraction, such as the use of heads-up display (HUD) technology. HUD projects information onto a clear screen fitted to the windscreen so there’s no excuse for taking your eyes off the road as all the information you need is literally right in front of you.

Semi-autonomous Parking guide

Another neat trick is the self-parking car, not just semi-autonomous parking where you steer or accelerate, but actual, ‘get out of the car and watch it park itself’ type self-parking. It sounds unbelievable but the reality is that the technology exists.

Who's Driving?


Autonomous displays in cars

Cars are clever; so clever that they can drive themselves. We might not see fleets of them on the roads just yet, but self-driving cars are already in use in some areas – such as Paris, Singapore and Milton Keynes (yes, really).

Safety isn’t just about steering the car away from accidents, some cars can monitor the health of the driver. Work at Ford – its Active Health Monitoring System keeps tabs on the driver’s heart rate through sensors in the car seat. If necessary, the seat would send alerts telling the driver to pull over and, worst case, the car could engage other safety systems to pull itself to the side of the road and call the emergency services.

Future-Proof, But Fool-Proof?


A technological tsunami has been upturning the automotive industry over the last decade. "This development will be in stages: we start without feet and then do without hands and eventually without eyes." Pascal Brier, Altran Group Executive Vice-President.

By 2050, the expectations of motoring and automobile technology are expected to reach impossible boundaries, most importantly in areas of sustainability and safety.

Think about it!

References


http://www.smartkeyplus.com/bbs/board.php?bo_table=review_en&wr_id=5

https://www.comparethemarket.com/car-insurance/content/latest-and-best-car-technology/

https://cars.usnews.com/cars-trucks/best-self-parking-cars

https://www.made-in-china.com/showroom/orange0311/product-detailYSpJoVByEsWr/China-Hot-Sale-E350-5-8-Inch-Car-Hud-Obdii-Aftermarket-Head-up-Display-Multifunctional-Dynamic-Speedometer.html

https://en.wikipedia.org/wiki/Automotive_night_vision

https://roadsafetyfacts.eu/active-safety-systems-what-are-they-and-how-do-they-work/

https://www.youtube.com/watch?v=xsQvq4WlUYU

https://media.daimler.com/marsMediaSite/en/instance/ko/ATTENTION-ASSIST-Drowsiness-detection-system-warns-drivers-to-prevent-them-falling-asleep-momentarily.xhtml?oid=9361586

https://www.buyacar.co.uk/cars/271/what-is-keyless-entry

https://www.engadget.com/2018/06/20/digital-car-key-standard/?guce_referrer=aHR0cHM6Ly93d3cuZ29vZ2xlLmNvbS8&guce_referrer_sig=AQAAABHbtFceiks9PZEXo0UD8G9cOYp7wFSoANrpkrfFCl10T957jV30s3qJkDPBKv3nYyhkphwnFCqCiTJUS-iPw0YKUEL1gUJuSuJxq5C-0Ed26lb9J30TtZ8ikojqXhb2mm4RkPnM7ArAVF6AllMO9Th7tGJI98vKUArMw39Oga9Y&guccounter=2

Sunday, January 3, 2021

JavaScript and Web: Film Warehouse

Film Warehouse

Web Development, BSc Computer Science group project, 2018.   You can find the project code by clicking the Github icon. ->GitHub



Introduction


The assignment was to create an e-commerce website. We were allowed to choose the product (groceries, hardware, services, tickets, holidays, etc.). Customers should be able to add items to a basket and enter their personal details (name, address, email, telephone number, etc.).

Why 'Buy Now' is clicked, a confirmation message is displayed and the order is stored. (For the ease of not having to deal with security issues, no payment will be displayed, required or stored.) No money is taken by the website and no confirmation email is sent.

A content management system will also need to be created, to enable staff to add products, view orders, etc. The website will track customers and provide recommendations/ Customers should be able to register on the site and view past orders.

For this assignment, we chose to sell films and DVDs and we chose to name this e-commerce store 'Film Warehouse'.

Film Warehouse logo

Main Website


The website was created in accordance with the requirements e.g. customer registration, login, customer tracking and so on.  Personal data would be stored on the server using MongoDB as a database. Data is expected to be accurately and efficiently stored.

A content management system (CMS) will also be put in place for easy adding of products and change of information by staff or admin.

MongoDB


Our database in MongoDB is named “ecommerce” and has the following collections:
- customers
- orders
- products
- staff

Ecommerce website

The website will have various pages which the user is able to access via the navigation bar added to the site. On entering the site, the user will see the homepage.

A few movies and TV shows and popular products should pop up on the main page. There will also be a recommendations area which will show a couple of movies and names of movies which have been searched in case a customer forgets what they searched for.

The search recommendation will be stored using HTML local/session storage. Finally, the footer will contain various social links and external links to leave reviews.


Next we have the Genres page. This page has a similar layout to the homepage minus the search and recommendations. 

It will have different genres such as children films, science fiction films and action films. This page has all products sorted in terms of genre. It will have the search, filter and sort options available, to allow for easy search and access for the customer.


Of course, as part of the requirements, a login and signup page was required. For the purpose of this assignment, a customer cannot make a purchase without an account. If not logged in and going to checkout, the customer will be redirected to login or sign up.


And finally, we have the checkout page. The checkout page is essential to complete and confirm the customer's purchase order. They are able to delete products in their basket, view their total costs and checkout.

From here they will be able to confirm the purchase where they will have to enter their login details if they haven’t already and then continue to payment.



Content Management System (CMS)


The e-commerce website has a content management system (CMS). From here, staff are able to add and delete products, and view and search for products and orders. AJAX is also incorporated, allowing for a couple of recommendations to the customers.



This is the login page, where you can add staff to the database, which is not the best way to go, in a real-world situation. There should be an admin allowed to add staff once logged in, but this is a basic project, and if allowed time, it could’ve been implemented.



The above is a View Products page, where, logged in, you can view all the products that are stored in
the database. It allows you to search by various keys and allows for sorting according to price and
name.

    


The above is a page for adding products to the database. Once you are logged in, you can
successfully add products. Staff can also change or update the data on existing products.


Testing


The test files are available in the folder. “PHPTests.php” is the main file used for the tests.
“db_tools.php” contains the utility functions used in the tests, and “db_interface” contains the rewritten code from the website, put into functions and run.

Five tests were written (in the file PHPTests.php) and passed:
- To add a customer
- To add a product
- The staff login
- Updating of a customer

JUnit testing was used for testing:
- The customer recommender
- The save function

Front-End testing (Selenium)
- Search and look for 'Tarzan'
- Checkout Page
- Genre page functionality
- Customer login
- Customer registration

Contributions and Third Party Libraries


Below is the third party library which was used for the footer. https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css

This project was done by Kristen Rebello, Ekin Pehlivan and Arshad Musejee.

Security, Privacy and Legal Issues


There are security, privacy and legal issues concerning the e-commerce website my group has
created, and because this was never to go live, has been ignored. The website is one which sells DVDs, and to make purchases, customers need to enter their personal details such as name, address, credit card information and so on.

Any sites that hold sensitive data are likely prone to get the attention of hackers. If this data is retrieved by an individual, they could send across spam, conduct phishing attacks, or in worst case, make unauthorized purchases through the customer's credit card details. This would likely mean a loss of money and reputation for the company.

Another security issue could be government putting legislation in place to weaken the e-commerce
websites security. This could result in it being easier for hackers to get into the website or the
government themselves. Once they do this, the government could spy on the customer's activity on the website.

A security issue for the e-commerce website could be activists performing a Denial of service attack
on the website. Activists may do this to deface the website for their own gain which could be raising
awareness of various issues and events, eg. political issues. If they do this they could spam the website, spy on the users of the website even find out their location which is a huge security risk.

When a credit card is used to make a payment, the location and content of the purchase will be tracked. A lot of people may not want their data shared with other companies, while there are other people who have no issue whatsoever having their data shared.

Due to the personal data being stored by the e-commerce website, the company could be liable if they do not have the correct security measures in place. However, legal liability needs to be made clear to the users before anything like this happens.

In order to battle these security issues we should ensure that the computers have firewall enabled and the operating system is up to date, along with the latest security updates installed. If these actions are taken then, the risk of being attacked/hacked is minimal.





 
Loading...