Environment Setup

FIND A SOLUTION AT Academic Writers Bay

Project 1
Due date: 09/29/2021
PART 1: Environment SetupPlease follow the instructions below to install VirtualBox on your computer.
On Windows
 

1 Open the VirtualBox website. Go to https://www.virtualbox.org/ in your computer’s Internet browser. This is the website from which you’ll download the VirtualBox setup file.

2 Click Download VirtualBox. It’s a blue button in the middle of the page. Doing so will open the downloads page.

3 Click Windows hosts. You’ll see this link below the “VirtualBox 6.1.14 platform packages” heading. The VirtualBox EXE file will begin downloading onto your computer.

4 Open the VirtualBox EXE file. Go to the location to which the EXE file downloaded and double-click the file. Doing so will open the VirtualBox installation window.

5 Navigate through the installation prompts. Do the following:
Click Next on the first three pages.
Click Yes when prompted.
Click Install
Click Yes when prompted.

6 Click Install when prompted. Doing so will allow VirtualBox to begin installing on your computer.

7 Click Finish when prompted. It’s in the lower-right side of the window. Doing so will close the installation window and open VirtualBox. Now that you’ve installed and opened VirtualBox, you can create a virtual machine in order to run any operating system on your PC.
Make sure that you don’t uncheck the “Start” box before doing this.
On Mac
 

1 Open the VirtualBox website. Go to https://www.virtualbox.org/ in your Mac’s Internet browser. This is the website from which you’ll download the VirtualBox DMG file.

2 Click Download VirtualBox. It’s a blue button in the middle of the page. Doing so will open the downloads page.

3 Click the OS X hosts link. You’ll find this option in the middle of the downloads page. The VirtualBox DMG file will begin downloading onto your Mac.

4 Open the “VirtualBox” DMG file. Once the VirtualBox DMG finishes downloading, double-click the file to open it.

5 Double-click the “VirtualBox.pkg” icon. It’s a brown box-shaped icon in the upper-left corner of the window. Doing so will prompt VirtualBox’s installation window to open.

6 Navigate through the installation prompts. Click Continue when prompted, then do the following:[1]
Click Continue in the bottom-right corner of the window.
Click Install in the bottom-right corner of the window.
Enter your Mac user password when prompted.
Click Install Software

7 Wait for the installation to complete. Once you’re prompted to click Close in the bottom-right corner of the window, you’ve successfully installed VirtualBox on your Mac.

8 Open VirtualBox. Click Spotlight 
type in virtualbox, and double-click VirtualBox in the resulting drop-down menu. Now that you’ve installed and opened VirtualBox, you can create a virtual machine in order to run any operating system on your Mac.
PART 2: Install a costume-built Linux OS as a VirtualBox ApplianceClick here to download the file OSC10e.ovaDouble-click on the downloaded file. This will open the following window
Choose the Import button.Running LinuxHighlight the virtual machine you wish to run (OSC10e) and click on the Start button:This will commence the Linux boot process.The default username is osc and the password is osc as wellThe password for the root user is oscThe home directory contains the source code for Operating System Concepts in the final-src-osc10e directoryThe README file includes other instructions as well, notably for finding the location of the bcc toolset.
PART 3: Access virtual machine and exchange files between host machine and virtual machine.
3.1 To access your virtual machine guest:On macOS (OS X)
Using terminal, enter the command
sftp -P 2222 [email protected]
This will provide you with ftp access to exchange files between your host and virtual machine guest.On Windows
We recommend using winscp, freely-available software.
3.2 Some useful commands:
passwd //change your password
mkdir <name of the directory> //make a new directory
cd <name of the directory> //change the directory
pwd //display the current directory
ls –l //list the files in the current directory
cp <name of the file> <name of the directory> //copy a file to a directory
mv <name of the file> <new name of the file> //rename a file
rm <name of the file> //delete a file
rm –r <name of the directory> //delete a directory
vi <name of the file> //use the text editor vi to edit a text file
man <name of the command> //display the manual of the command
!pwd //display the current directory on the local end
!ls -l //list the files in the current directory on the local end
lcd <name of the directory> //change the directory on the local end
pwd //display the current directory on the remote end
ls –l //list the files in the current directory on the remote end
cd <name of the directory> //change the directory on the remote end
put <file name> //upload a file from the local end to the remote end
get <file name> //download a file from the remote end to the local end
mput *.c //upload all .c files from the local end to the remote end
mget *.c //download all .c files from the remote end to the local end
gcc -o <name of the output file> <name of the .c file> //compile a .c file
//Example: gcc -o Sample Sample.c
./<name of the output file> //run an executable file that’s in current directory
//Example: ./Sample
ps –ef |grep <name of the program> //list info for process(es)
kill -9 <Process ID of a process> //kill a process with given PID
PART 4: Programming – Sudoku Solution Validator.
Write a C program for Project 1 – Sudoku Solution Validator.
A Grading:
Your program will be graded via testing and points are associated with how much task it can complete. A program that cannot
be compiled or crashes while running will receive up to 5% of the total points. A submission of little change to the example .c provided
by the instructor will receive up to 3% of the total points.
B. Project Description:
This programming project is the Project 1 defined in pages P-27 through P-29 at the end of Chapter 4
(Threads & Concurrency) in Textbook (10/E). Please read the textbook for details.
C. Program Design and Additional or Modified Requirements:
These requirements must be followed in addition to what is defined in the textbook. If it is not the same as what is described in the textbook, please follow the description/requirements in this document.
1. Inputs and Data structures:
1.1 This C program must read a 9 x 9 Sudoku puzzle from an input text file named “SudokuPuzzle.txt” into a 9 x 9 matrix (2
dimension int array), e.g., sudokuPuzzle[9][9]. This file must consists of 9 rows. The i-th row in the file “SudokuPuzzle.txt” consists of the 9 integers in the i-th row of a given Sudoku puzzle, where tab (‘t’) must be used to separate those numbers in each row of the file. For example, the first two rows in this file for the puzzle shown in Figure 4.26 should be
6 2 4 5 3 9 1 8 7
5 1 9 7 2 8 6 3 4
……
This C program must print the matrix sudokuPuzzle[ ][ ] after reading it from the input file
(Hint: fgets() can be used for reading a line from a file into a char array, whose size (like 50) needs to be large enough to hold all characters in each line including the newline character.
Please study how to open/close a file in C, how to use fgets() to read each line from a file, and how to read each integer from a string where integers are separated by tab (‘t’) and the last integer is followed by a new line character or NULL.)
1.2 The following shared data structures must be declared as global variables such that they are shared by all threads
1.2.1 sudokuPuzzle[9][9], a two-dimension integer array recording all numbers in the given Sudoku puzzle.
1.2.2 a 9-element Boolean array for 9 columns, where elements [0] through [8] are true or false if columns 1 through 9 in the Sudoku puzzle are valid or invalid, respectively. (Hint: you might have to use “typedef int bool;” and then use #define to define your own TRUE and FALSE.)
1.2.3 a 9-element Boolean array for 9 rows, where elements [0] through [8] are true or false if rows 1 through 9 in the Sudoku puzzle are valid or invalid, respectively.
1.2.4 a 9-element Boolean array for 9 3 x 3 subgrids, where elements [0] through [8] are true or false if 3 x 3 subgrids 1 through 9 in the Sudoku puzzle are valid or invalid, respectively. Subgrids are numbered from left to right, top to down. The 1st 3 x 3 subgrid is the intersection of rows 1 through 3 and columns 1 through 3, the 2nd 3 x 3 subgrid is the intersection of
rows 1 through 3 and columns 4 through 6, …, the 4th 3 x 3 subgrid is the intersection of rows 4 through 6 and columns 1 through 3, …, the 9th 3 x 3 subgrid is the intersection of rows 7 through 9 and columns 7 through 9.
1.3 typedef a structure to represent the index (row and column) range of the elements in a Sudoku puzzle to be processed by each worker thread created by the parent thread. This structure must include the following four integers.
int topRow; //index (0, 1, …, or 8) of top row to be checked by a worker thread
int bottomRow; //index (0, 1, …, or 8) of bottom row to be checked by a worker thread
int leftColumn; //index (0, 1, …, or 8) of left column to be checked by a worker thread
int rightColumn; //index (0, 1, …, or 8) of right column to be checked by a worker thread
For example, in the format of (<topRow>, <bottomRow>, <leftColumn>, <rightColumn>), the 1st column is represented by (0, 8, 0, 0), the 3rd column is represented by (0, 8, 2, 2), the 8th row is represented by (7, 7, 0, 8), the 2nd subgrid is represented by (0, 2, 3, 5), the 7th subgrid is represented by (6, 8, 0, 2), etc.
2. Worker threads: in this program, the parent thread must create 27 worker threads, one for each column, row, or subgrid.
2.1 The parent thread first initializes 9 structures in an array of structures type-defined in 1.3 to represent 9 columns, where for
the k-th column, topRow is 0, bottomRow is 8, and both leftColumn and rightColumn are (k –1).
Next, the parent thread creates 9 worker threads, one for each column, and records the thread id of each worker thread in a tid_column[] array. To the worker thread for the k-th column, the parent thread passes the address of the structure initialized earlier for the k-th column as a parameter.
2.2 The parent thread first initializes 9 structures in an array of structures type-defined in 1.3 to represent 9 rows, where for the k-th row, both topRow and bottomRow are (k – 1), leftColumn is 0, and rightColumn is 8.
Next, the parent thread creates 9 worker threads, one for each row, and records the thread id of each worker thread in a tid_row[] array. To the worker thread for the k-th row, the parent thread passes the address of the structure initialized earlier for the k-th row as a parameter.
2.3 The parent thread first initializes 9 structures in an array of structures type-defined in 1.3 to represent 9 subgrids, where for the 1st, 2nd, and 3rd subgrids, topRow is 0 and bottomRow is 2, for the 4th, 5th, and 6th subgrids, topRow is 3 and bottomRow is 5, for the 7th, 8th, and 9th subgrids, topRow is 6 and bottomRow is 8, for the 1st, 4th, and 7th subgrids, leftColumn is 0 and rightColumn is 2, for the 2nd, 5th, and 8th subgrids, leftColumn is 3 and rightColumn is 5, and
for the 3rd, 6th, and 9th subgrids, leftColumn is 6 and rightColumn is 8. Next, the parent thread creates 9 worker threads, one for each subgrid, and records the thread id of each worker thread in a tid_subgrid[] array. To the worker thread for the k-th subgrid, the parent thread passes the address of the structure initialized earlier for the k-th subgrid as a parameter.
2.4 Each worker thread must check all the nine cells in the Sudoku puzzle that are assigned to this worker thread (hint: index range in sudokuPuzzle[][] is topRow <= row index <= bottomRow and leftColumn <= column index <= rightColumn)
If those nine cells contain each of 9 digits (1 through 9) exactly once,
1) set the corresponding entry in the Boolean array declared in 1.2.2 for columns, 1.2.3 for rows, or 1.2.4 for subgrids as TRUE
2) Display the following message in a new line to stdout, where each < … > must be replaced by the corresponding value
<worker thread ID in HEX> TRow: <topRow>, BRow: <bottonRow>, LCol:<leftColumn>, RCol: <rightColumn> valid!
Otherwise, if those nine cells do NOT contain each of 9 digits (1 through 9) exactly once,
1) set the corresponding entry in the Boolean array in 1.2.2 for columns, 1.2.3 for rows, or 1.2.4 for subgrids as FALSE
2) Display the following message in a new line to stdout, where each < … > must be replaced by the corresponding value
<worker thread ID in HEX> TRow: <topRow>, BRow: <bottonRow>, LCol:<leftColumn>, RCol: <rightColumn> invalid!
2.5 The parent thread must wait for all 27 worker threads to complete, then the parent thread
1) Display the contents of tid_column[] array and the Boolean array declared in 1.2.2 in nine lines to stdout, where each < … > must be replaced by the corresponding value
Column: <TID in HEX> <”valid” or “invalid” depending on its entry in the Boolean array>
2) Repeat 1) for rows by using the info in the tid_row[] array and the Boolean array declared in 1.2.3
Row: <TID in HEX> <”valid” or “invalid” depending on its entry in the Boolean array>
3) Repeat 1) for subgrids by using the info in the tid_subgrid[] array and the Boolean array declared in 1.2.4
Subgrid: <TID in HEX> <”valid” or “invalid” depending on its entry in the Boolean array>
4) Display the final conclusion “valid” (“TRUE” in all entries of all three Boolean arrays) or “invalid”
Sudoku Puzzle: <”valid” or “invalid” depending on all values in three Boolean arrays>
GOOD LUCK!
References
https://www.wikihow.com/Install-VirtualBox
http://people.westminstercollege.edu/~greg/osc10e/vm/index.html

Order from Academic Writers Bay
Best Custom Essay Writing Services

QUALITY: 100% ORIGINAL PAPERNO PLAGIARISM – CUSTOM PAPER