Operating systems portfolio

Page 1

Operating Systems Portfolio Practical 1 

Exploring the use of commands with options and arguments

Taking a selection of Windows CLI commands from those given below, use the online help to examine the various options and arguments, and try them out. You can look up others at: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/enus/ntcmds.mspx?mfr=true

You're required carefully to write two A4 pages (Times 12 point or equivalent size) detailing your experiments with different options for between six and ten different commands.

To get the online help for a command, type command /?

Exploring the use of commands with options and arguments Dir: The “Dir” command lets a user display a list of files and sub directories within a directory. It also displays the disk volume label, serial number, total number of files in the directory and the space remaining on the disk. Dir can be used with other commands such as “/d” to display the files and subdirectories in columns rather than down in a straight list which is useful for long directories. Another command that Dir can use is “*.file extension type”. This can be used to display a specific extension type that might be in the directory so that it filters out all the other types.

Mkdir: The “Mkdir” command lets a user make a directory or subdirectory. To do this you can do it in two different ways, one of the ways you can use the command is by simply navigating to the folder that you want to make the sub directory or directory and then typing in “Mkdir foldername”. Another way you can do this is by navigating to the folder in the same command “Mkdir C:\Users\Danny\foldername”. Another command that can achieve the same as Mkdir is the MD command which also makes directories.

Color: The “Color” command allows a user to change the colors within command prompt to whatever they like. The way they can do this is by using a hexadecimal table which gives a number or letter for each value. To use this you type in “Color (Value of the color you want for the background)(Value of the color you want for the text)”. An example of this would be to use “Color FC” which will give you a white background with yellow text. By typing in just “Color” it will take you back to the default command prompt.

Title: The “Title” command allows a user to change the name at the top of the command prompt to whatever they like. To do this they can type “title (nameoftitle)”. To reset the title


you can just type in “title” to the command prompt and this will allow you to reset the title back to the default.

Tree: The “Tree” command allows a user to display the directories structures in a graphical format.


Practical 2 To do:

(4a) Create another file called beverage.txt identical to drink.txt. (Hint: Use what you learned in practical 1 to do this.) (4b) Issue this command again PS C:\Users\User1\green> Get-ChildItem | select-string coffee and see what happens.

(4c) Create a file called fruit.txt with the list

apple orange banana

in it.

(4d) Issue this command again PS C:\Users\User1\green> Get-ChildItem | select-string coffee and see what happens.

(4A – 4D)


The first thing that I done was copy the file “drink.txt” to “beverage.txt”. I then used the new command provided to search the directory for the string “coffee” that was located in “drink.txt” and “beverage.txt”. Then I created another file called fruit.txt which didn’t have coffee in it and searched using the same command and got back the same results from the directory.

To do:

(10a) Test the above using your directory created earlier in part 4.

(10) The first thing I am doing is setting up an array and it is storing the directories from the dir command. The next thing that I have done is use the command “$mylist” to give back the information on the directories the same way the command “dir” does. Then I am using the command “$mylist[0].Name” to give back the name of the file located in the first position of the array. The last thing I have done is used the command “$mylist[1].length” to go to the second position in the directory and get the length of the file.

To do:

13(a) Simply record what happens when you run this script.


(13a) I ran the script by typing the command “.\firstscript.ps1. “ this then displays the text “Please type your name” and it is storing it and then on the next line it is printing out whatever you typed and before that “Hello”.

13(b) Find out how to run scripts if they’re in a directory other than the working directory.

14.

Concluding Things to Do

Watch the video at the first of the two links below and then (using the video or other sources) answer the following questions.

1. Explain why it’s found that people who know PowerShell well score the same sort of marks in tests of their knowledge regardless of whether they’re first rate experts or just people who know PowerShell well. What is it that gives the first-rate experts the edge? 2. Find out and explain how to get help about any cmdlet. 3. Find out and explain what F7 does in PowerShell. 4. What is the purposes of (a) the –whatif switch and (b) the –confirm switch in PowerShell. 5. Write a note to explain how you can use tab to complete a command as soon as it’s unambiguous.


1. 2. You can use the command Get-Help 3. Displays a list of previously executed commands. 4. –whatif: Makes it so the command is tested but it isn’t actually carried out -confirm: Makes it so the command is carried out. 5. You can use a tab to finish out a command when you get into a certain length, this can even be used for files e.g. “Desk” then tab for Desktop etc.


Practical 3 Exercise 1 Simply record what happens when you run this script. What difference does it make if you leave out the text "Please type your name" from the first line of the script? If you leave out the text, it will still run the script but wont show the person what to do and it will still expect input. Exercise 2 Find out how to run scripts if they’re in a directory other than the working directory. Exercise 3 (a) Find out how to do the same thing that the code above does except that it’ll only accept integers (such as 67). (b) Once you’re found the answer, find out what happens if you type a real number (such as 67.4 or 67.8) 3a) To print out just integers instead of doubles, you change the double value so your code ends up like this: $inputString = read-host $value = $inputString -as [Int] write-host "You entered: $value"

Exercise 3: What does the above script do? The code uses I as a loop control variable and it gets incremented by one each time and starts at 1. In the while loop it has validation that the loop control variable can’t be more than 20, it then goes into an if statement which checks that the number is not 13 or 17 and if it is not one of these numbers, it prints it out to the command prompt.


Exercise 4: We don’t need the brackets round ($i -ne 13) and ($i -ne 17) in the code above. Why do we not need them? (Hint: The answer is the same as for Java). Do you think that it’s a good idea to put them in even if they aren’t necessary? Explain your answer. You don’t need the brackets around “($i – ne 13)” and “($i –ne 17)” because

Exercise 5: We can replace $i = $i + 1 with something shorter, in the above two scripts. What do you think it is? Try it and see. Instead of using “$i = $i + 1” you can just increment it by one by using “$i++” for($i = 1; $i -le 8; $i++) { Write-Host $i }

Exercise 6: Oops, I've put semicolons at the end of each of the lines, in the do...until loop above. I suppose it's because of my experience in writing programs in other languages that sometimes I put semicolons at the end of a line of PowerShell script, even when they're entirely unnecessary in PowerShell. Does PowerShell forgive me for doing this? Find out, and write your conclusion. Yes powershell will still allow the script to run.

Exercise 7: Alter this program to deal with grade categories (for example >70 is a distinction mark etc) in an examination and also allow the user to enter a grade. write-host -nonewline "Enter your mark: " $grade = read-host $grade -as [Double] switch($grade) { { $_ -lt 40 } { "Fail"; break } { $_ -le 59 } { "Pass"; break } { $_ -le 69 } { "Merit"; break } { $_ -le 100} { "Distinction" } }


Exercise 8. Explain what the above example does. Modify it to show fields other than the Name field. It is storing the dir command into a variable called “listing�. It is then setting up an array to store the length of the listing. It is using I as a loop control variable where it will run until it is exceded the length of the array. Inside the while loop it is showing the name of each directory or file is in the current directory.

Exercise 9. Draw up a chart to show equivalent syntaxes for different control structures/data structures among Java, Unix script, and PowerShell. You'll have to revisit this question when you've learned some Unix/Linux.

Exercise 10. Compare the ways in which scripts are enabled to run in (a) Unix/Linux and (b) PowerShell. Again this is a question for review when you've done some Unix/Linux.


Practical 4

Things to do: 11.1 Find out, by using different values of the numerical parameter, what the following useful line of PowerShell does: dir | where-object {$_.LastWriteTime –lt (get-date).addmonths(-6)} It displays the last write time of the files. So by changing the parameter to say “-1000” you may not get any results since there was no file wrote then. Things to do:

11.2 There is another way of single stepping through a script, using F10. Find out and explain what F10 does, comparing it with F11. F10 allows you to go through the code line by line where as with f11 it goes to the actual function the script is carrying out.


Practical 5 To do:

1. Find out what happens when you type time at the command line in (a) UNIX and (b) Windows CLI Windows CLI: In windows CLI, the time command displays the current local time of the computer. Ubuntu:

Real: The whole time User: Executing code Sys: Amount of time spent by the system

If you have time left over from the above, please use that time to make your own summary of the last three practicals. You can also make your own table of Windows CLI, Windows PowerShell and Unix commands, that will be less extensive than the one I’ve given on moodle. If you haven’t got time during class, please do it at home, and put it in your portfolio.


Practical 6 Exercise: 1. One might have supposed that echo would work on the last line above instead of expr. Try it with echo and see what happens. Later we’ll see a way of doing what this program does using echo. Echo prints it out as a string. 2. Something for you to find out: Find out how to do multiplication in Linux script. It is not as you might suppose, simply by replacing + with * You can do it as: \\*


Practical 7

Exercises: 1. Create, using touch, four files called apple, orange, banana and grape.

(a) Determine the initial permission values for these newly created files.

(b) State what the read, write and execute permission will become for the following chmod commands: chmod chmod chmod chmod

642 777 547 444

apple orange banana grape

Now try it out on your computer, and, by using ls –l, check your work. chmod 642 apple User: Read and Write Group: Read Other: Write

chmod 777 orange User: Read, Write and Execute Group: Read, Write and Execute


Other: Read, Write and Execute

chmod 547 banana User: Read Group: Execute and Write Other: Read, Execute and Write

chmod 444 grape User: Read Group: Read Other: Read

2. Continue now, by issuing the following command: chmod u+x grape. What do you predict will be be the read, write, execute permissions now? Check your answer by using ls -l Chmod u+x grape User: Read Group: Execute and Write Other: Read


3. Make the file called orange have the same permissions as the file called apple.

4. Put all the files, apple, orange, banana and grape, into a directory called testmod. In testmod create a directory called testmodsub and using touch create two files called red and blue. You now have a small directory tree.

Now go back to the directory containing testmod and change the permissions of all the files recursively in the directory tree starting at testmod, such that each file will now have the permission 757.



Practical 8 Exercise 1: Find out what is listed by:

$ ls ~

ls ~ displays a directory of the home files no matter what directory you are currently in.

Exercise 2: Find out what is listed by:

$ ls ~/.. ls ~/.. displays the username of the operating system.

Exercise 3: Find out what

$ cd ~/

does.

cd ~/ goes back to the home directory from wherever you currently are.


Exercise 4:

Using the above method create another file called list 2 containing the following fruit: orange, plum, mango, grapefruit. List the contents of list 2.

Exercise 5: Find out what happens if you do

cat >> mondaylist rabbit hare ^d

and mondaylist doesn’t yet exist.

Using the command without having the file created still works. Exercise 6: Find out what happens if you do:


cat >> mondaylist rabbit hare ^d

and mondaylist does already exist.

It works the same was it normally does by adding the text to the bottom of the file.

Exercise 7:

Using pipes, display all lines of list1 and list2 containing the letter ‘p’ and sort the result. ls linuxstuff/backups lists the files that are located in the directory backups which is a subdirectory of linuxstuff

ls ~/linuxstuff displays the list of subdirectory’s and files in the linuxstuff directory.

ls ~ lists all the files and directory’s on the home path.


Exercise 8:

Using pipes and filters search all files ending in *.txt in your linuxstuff directory that contain the names of ALL other users in your class currently logged in. Output the results in ascending order to Standard Output. ls ~/.. displays the current users, username for the operating system.

cat > list1 … ^D cat > list1 allows a user to create a list. It is then putting in “…” and then control d to exit back out and save it.

Exercise 9:

Explain what the following do:

a.

ls linuxstuff/backups

b.

ls ~/linuxstuff

c.

ls ~

d.

ls ~/..

e.

cat > list1 … ^D

f.

cat >> list1 … ^D

g.

cat list1

h.

cat list1 list2 biglist

i.

sort … ^D

j.

sort < biglist

k.

sort < biglist > slist

l.

ls list*


m.

ls *list

n.

ls ?list

o.

who

p.

who > names.txt sort < names.txt who | sort

q.

who | wc –l

r.

grep 'orange' list2

s.

grep '^grape' list2

t.

grep 'grape$' list2

cat >> list1 … ^D this allows you to edit to the bottom of the file to add information into it. cat list1 this displays the list. cat list1 list2 biglist This combines list one and two to create another list called biglist. sort … ^D This sorts the content in the file and exits using ^D. sort < biglist This sorts the content of the biglist into alphabetical order. sort < biglist > slist This sorts a list into a new list called slist. ls list* This is a wildcat operator that searches for a list of files that start with list ls *list This does the opposite so it searches for a list that ends with list ls ?list This searches for one characted before list and then displays it into a list. who Shows who is currently on the system. who > names.txt This shows who’s currently on the system to names.txt sort < names.txt Sorts the file names.txt who | sort Will get the names and then sort them.

2. Write a note to explain the difference between ~ and / in describing directories.


Practical 9 Exercise 1

Now try setting the permission to 640. Write down the 9 character rwx pattern.

Exercise 2

Devise some experiments to see if you can test the effect of the nice command.

(a) What is the difference between typing fg (i) with a job number specified and (ii) without a job number specified? (b) What do you type to (i) cancel a process (b) suspend a process. (c) Explain the difference between the ps command and the jobs command. (Hint: You may wish to consult the Internet to help find answers to this.) (d) Write a tutorial style note, for first year students, showing the various switches (i.e. options) that are available for the ls command. (Hint: You may wish to consult the Internet to help find answers to this.)


Practical 10 Things to try part 1.1:

1. Create an Eclipse Java Project to use this program and run the software 10 times, each time copying and pasting your results into a word processor file. Label this set of 10 results clearly with the heading Threading Program 1.1 Threading Program 1.1 1. aaaaaaaaaaaaaaaaaaaaaaaaaaa 1b 2a 3bbbbbbb 4aaaaaaaaaaaaaaaaaaaaaa 5b 6aa 7b 8a 9b 10a 11bb 12aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 13bbbbbbbbb 14aaaaaaaaaa 15b 16bbbb 17bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 18b 19b 20b 21b 22b 23b 24b 25b 26b 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 2. bbbbbbbbbbbbbbbbbbbbbbbbbb 1aaaaa 2bbbbbb 3 4aa 5 6 7 8b 9a 10 11b 12 13a 14 15 16 17b 18aaaaa 19 20b 21 22 23aaaa 24bbbbbbbbbbbbbbbbbbbbb 25 26 27a 28b 29 30 31a 32bbbbbbbbbbbbbbb 33a 34 35 36b 37 38 39 40 41 42 43 44a 45 46 47 48b 49a 50b 51a 52 53b 54a 55b 56a 57bbbbbbbbbbbbbbbbbbbbbb 58 59 60 61a 62aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 63a 64aaaaaaaaa 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 3. babaaaabaaaaa 1aba 2aba 3aba 4aba 5aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaba 6aaaaaaaaaabbbbba 7aaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaa 8b 9bb 10bbbbbbbbbb 11bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 12b 13b 14b 15bbbbbbbbbbbbbbb 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 4. aa 1 2 3bb 4 5 6 7 8 9 10aaa 11 12 13 14bbbbbbbbb 15aaaa 16b 17aaaaaaaaaaa 18 19b 20 21 22aaaaaaaaaaaaaaaaaaaaa 23b 24a 25b 26aaaaaaaaaaaaaaaaaa 27bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 28aaaaaaaa 29bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 30 31 32a 33aaaaaaaaaaaaaaaaaaaaa 34aaaaaaaaaa 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 5. abaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 1bbbbbbbabbbbbb 2baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab 3baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab 4bbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaa 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 6. a 1bbbbbbbbbbbbbbb 2a 3bbb 4aaaa 5b 6a 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27bbbbbbbbb 28 29 30 31a 32b 33a 34b 35a 36 37 38 39 40b 41a 42b 43a 44b 45a 46bbbbbbbbbb 47a 48b 49a 50 51 52b 53 54a 55 56 57 58 59 60 61 62 63 64b 65 66a 67 68b 69a 70b 71aaaaaaaaa 72b 73bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaa


aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab 74a 75a 76aaaaaaa 77aaaaaaaaaa 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 7. abaaaabaaaaaaaaaaaaaaaaaaaaaaaaaa 1aba 2 3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbba 4abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaa 5aaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbba 6aaaa 7aaaaaaaaaa 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 8. aaaab 1 2a 3bbbbbbbbbbbbbbbbb 4aaaa 5bbbb 6a 7b 8aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 9bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbb 10a 11aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 12aaaaaaaaaa 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 9. abbbbbbbbb 1baaaabbbbbbbbbbbbbbbbbb 2bbabbbbb 3babbbbb 4bbaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbb 5bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbab 6bbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaa 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10. a 1 2b 3 4aaaaaaaaaaaaaaaaaaaa 5 6 7bbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaab 8 9 10 11 12 13 14 15baaaaaaaaaaaaabbbbbbbbbbb 16bbbbaaaaaaaaaaaaaaaaaaab 17baaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbb 18 19 20aaaaaaaaaa 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

Do you see much variation on your results from one run to the next? Explain what conclusions you come to.

2. If possible, repeat the exercise above with computers that are single core, dual core and quad core. Is there a difference in how these machines perform?

3. Replace the lines:

thread1.start(); thread2.start(); thread3.start();


with

thread1.run(); thread2.run(); thread3.run();

Does your software still run? If it does, what difference do you see?

The software still runs with the results: 1. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

Things to try part 1.2:

1. Create an Java Eclipse Project to use this program and run the software 10 times. Each time copy and paste your results into a word processor file. Label this set of 10 results clearly with the heading Threading Program 1.2 Threading Program 1.2 1. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccc 1 2 3 4 5c 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20c 21c 22cccccccccccccccc 23cccccccc 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 2. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccc 1 2 3 4 5 6 7ccccccccccccccccccc 8c 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25


3.

4.

5.

6.

7.

8.

9.

26 27 28 29 30 31 32 33 34 35 36ccccccccc 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccc 1cccc 2 3 4 5 6cccccc 7ccccccccccccccccc 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccc 1 2 3cccccccccccccc 4 5 6 7cccc 8ccccccccc 9 10ccc 11 12c 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccc 1 2 3 4 5 6 7 8 9 10 11 12 13 14cc 15 16 17 18 19 20 21 22 23 24ccccccccccccccccccccc 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccc ccccccccccccccc 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccc ccccccccccccccc 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccc 1ccccccccccccccccc 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb


bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccc 1ccccccc 2 3 4 5 6 7 8 9cccccc 10ccccccccccc 11c 12c 13c 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccc ccccccccccccccc 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

Do you see much variation in your results from one run to the next? Explain what conclusions you come to.

Things to try part 1.3:

1. Create an Eclipse Java Project to use this program and run the software 10 times, each time copying and pasting your results into a word processor file. Label this set of 10 results clearly with the heading Threading Program 1.3 Threading Program 1.3 1. aaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbaaaa 1aba 2aaaaaaaaaaaaaaaaaabbbba 3abbbbbbbbba 4aaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 5aaaaabaa 6b 7bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 2. aaabbbbbbbbbbbbbbbbbbbbbbbb 1a 2 3 4b 5 6 7a 8b 9a 10 11 12 13 14 15 16 17 18bbbbbbbbbbbb 19a 20b 21aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 22bbbbbbbbb 23aaa 24 25 26 27b 28 29a 30b 31a 32bbbbbbbb 33aaaaaaaaaaaaaa 34bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 35a 36aaaaaaaaa 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 3. aaaaaaaaaaaaaaaabbbbbbbba 1aaaaaaaabbbba 2 3 4abbbba 5 6 7 8abba 9aaaaaabbbbbbaaaaaaaa 10 11aabbbbbba 12 13 14abbbbbba 15 16 17 18 19 20 21 22 23 24 25abbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaa 26aaaaaaaaaaaaaaaaaaaaaaaab 27b 28bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 29bbbbbbbbbbbbbbbbbb 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100


4. aaaaaaaaaaaaaaaabbbbbbbba 1aaaaaaaabbbba 2 3 4abbbba 5 6 7 8abba

5.

6.

7.

8.

9.

10.

9aaaaaabbbbbbaaaaaaaa 10 11aabbbbbba 12 13 14abbbbbba 15 16 17 18 19 20 21 22 23 24 25abbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaa 26aaaaaaaaaaaaaaaaaaaaaaaab 27b 28bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 29bbbbbbbbbbbbbbbbbb 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 aaaaa 1 2 3bbbbbbbbbbbbbbbb 4 5 6 7aaaaaa 8 9 10 11b 12a 13b 14a 15bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 16aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 17bbbbbbbbbbbbbbbbb 18aaaaaaaaaaaaaaaaaa 19b 20a 21bbbbbbbbbbbbbbbbbbbb 22a 23aaa 24a 25a 26a 27a 28aaaaaaaa 29a 30a 31a 32a 33aaaa 34aaaaaaaaaa 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 b 1aaaaaaaaaaaaaaa 2b 3baaaaaaaaaaaaaaaaaaaab 4bbaaaaaaaaaaaaaab 5baaaaaaaaaaaaaaab 6bbab 7b 8 9 10a 11b 12b 13 14a 15b 16a 17bbb 18aaaaa 19bbbbbbbbbbbbbbbbb 20 21 22a 23b 24aaa 25b 26a 27b 28a 29b 30a 31b 32aaaaa 33bbbbbbbbbbbbb 34 35 36 37 38 39 40 41 42a 43b 44aa 45b 46a 47b 48a 49b 50aa 51bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 52a 53aaaaa 54aa 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 a 1bbbbbbbbbbbbb 2 3 4a 5bbbbbb 6 7 8 9 10 11 12 13aaaaaaaaaaaaaaaaaaaaaaaaaaaa 14bbb 15aaaaaaaaaaaaaaaaaaaaaaa 16b 17aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 18bbbbbbbbbbbbbbbbbb 19aaaaa 20bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 21aaaaaaaaaa 22b 23bbbbb 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 baaaa 1b 2a 3bbbbbbbbbbbbbb 4aa 5b 6a 7b 8aaaa 9bbbb 10aaaaaa 11bbbbbbbbbb 12a 13bb 14a 15bbbbbbbbbbbbbbbbbbbbb 16a 17b 18a 19b 20aa 21b 22aaa 23b 24a 25b 26 27aaaaaaaaaa 28b 29a 30bbbbbbbbbbbbbbbbbbbbbb 31a 32b 33a 34b 35a 36b 37a 38bbb 39a 40b 41a 42bbbb 43a 44b 45a 46 47b 48a 49b 50a 51b 52aaaaaa 53b 54a 55b 56a 57a 58aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 59a 60aaa 61a 62aaaaa 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaba 1a 2bbbbbbbbbbbb 3a 4bbbbbbbbbbbbbbbbbbbbbb 5aaaa 6b 7aaaaaaaaaa 8 9 10 11b 12bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 13bbbbbbbbbbbbb 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 abbbbbbbbabbbbbbbbbbbbbbbb 1bbaaabbbbbbbbbbbbbbbbbbbbbbbbbbb 2bbbbab 3bab 4bbbbab 5babbb 6bbab 7bab 8bbbabbbbbbbbbbbbbbbbbbbbbbb 9a 10a 11 12a 13 14 15a 16 17 18a 19 20 21a 22a 23a 24a 25a 26aaaaa 27aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 28 29 30a 31a 32a 33a 34a 35a 36a 37a 38 39 40 41a 42a 43a 44a 45a 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100


Do you see much variation in your results from one run to the next? Explain what conclusions you come to.

Things to try part 1.4:

1. Create a JavaEclipse Project to use this program and run the software 10 times, each time copying and pasting your results into a word processor file. Label this set of 10 results clearly with the heading Threading Program 1.4 1. aabbaaabbbbbbaaaaaaaaabbba 1aba 2 3 4 5aaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaa 6aaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbba 7a 8a 9aaaaaaaaaaaaaaaa 10aaaaaa 11aaaaaaaaaa 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 2. aaaaaaaaaaaaaaaaaaaaaaaaaaabaaaa 1 2 3aba 4 5 6 7aaaaaaaaaaaabaaaaaaa 8aba 9aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaa 10b 11bbbbbbbbb 12bbbbbbbbbbbb 13bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 14bbbbbbbbbbbbbbbbbbbbbbbbbb 15bbbbbbbbbbbbbbbb 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 3. abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaabbbbbbbbbbbbbbb 1bab 2bab 3babbbbbbbbbbbbbbbb 4bab 5baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab 6bbbbbbbbbbbbbbbbbbbbbbba 7a 8aaaaaaaa 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 4. abaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbab 1 2 3baaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbb 4 5bbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbb 6babbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 7a 8aaaaaaaaaaaaaaaaaaaaa 9aaaaaaaaaa 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 5. abbbbbbbbbbbbbbb 1aaaaaaaaaaaa 2b 3aaaaaa 4b 5a 6bbbbbbb 7aaaaaaaaaa 8b 9a 10bbbbbbb 11a 12b 13aaaaaaaaaa 14bbbbbbbbbbbbbbbb 15aaaaaaaaaaaaaaaa 16bb 17a 18b 19a 20b 21a 22bbbbbbbbbbbb 23aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 24b 25b 26bbbbbbbbbb 27bbbbbbbbbbbbbbb 28bbbbbbbb 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 6. abaaaabbbbbbbaaaaaaaaaaaaaaaaaaaaabbbbbbbbb 1bbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbb 2baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbb 3a


4aaaaaaaaaaaaaaa 5aaaaaaaaaa 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 7. aaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaab 1 2 3 4 5 6 7 8 9 10b 11 12b 13b 14b 15b 16b 17b 18b 19b 20b 21b 22b 23bbbbb 24bbb 25 26 27b 28 29 30b 31b 32b 33b 34b 35 36 37b 38 39 40b 41b 42b 43b 44b 45b 46b 47bbbbbbbbbb 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 8. abbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaab 1bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaa aaaaabbbbbbb 2 3 4aaaaaaaaaaaaaaaaaaaaaaaaaaaa 5aaaaaaaaaa 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 9. aabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaabbbbbbbbbbbbbbbb 1baaabbbbbbb 2baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab 3bbbbbbbbaaabbbbbbbbbbbbbbbbbbbbbbbb 4a 5aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 6a 7a 8a 9aaaaa 10aaaaaaaaaa 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10. abbbbbbbb 1aaaa 2bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3a 4b 5aaaaaaaaaa 6b 7aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 8bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 9aaaaaaaaaaaaaaaaaaaaaa 10a 11a 12aaaaaaaaaa 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

Do you see much variation in your results from one run to the next? Explain what conclusions you come to.

2. Repeat part one above several times, each time with a different sleep time. Write out your conclusions. Sleep time 2: aaaaabaaaaaaa 1bbbbbbb 2 3 4aaaaaaaaaaaaaaaaaaaaaaaaaaaaa 5 6 7 8 9 10 11 12 13 14 15 16 17b 18 19 20 21 22 23 24 25a 26b 27a 28b 29 30aaaaaaaaaaaaaaaaaaaaa 31bbbbbbbbbbbbbbbbbbb 32baaaaaaaaaaaaaaaaaaaaaaaaaab 33baaab 34bbbbbbbabbbbbbbbbbbbbbbbb 35bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbba 36 37a 38a 39aaa 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100


Sleep time 3: aaaaaaaaaaabbaaaaabbbbbbbbbbbbbbbbaaaa 1 2 3 4b 5a 6b 7 8 9 10 11a 12b 13a 14b 15a 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30b 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50aaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 Sleep time 4: aaaaababbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbaa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23bbbbbbbbbbbbb 24bb 25bbbb 26bbbbbb 27 28 29 30 31 32 33 34 35 36bbbb 37b 38b 39bb 40b 41b 42b 43b 44 45 46bbbbbbbbbbbbbbbbbbbbbbbbbbbbb 47b 48b 49 50bbbbb 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 Sleep time 100: aaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbb 1bbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbb 2baaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3bbbbbbbbbaaa 4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 5aaaaaaaaaa 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

Things to try part 1.5:

1

Consider now the program for part 1.1 above and, in particular, the following lines:

// Third code block: Start threads thread1.start(); thread2.start(); thread3.start();

Now change these lines to read:

// Third code block: Start threads thread1.start(); thread2.start();


thread3.setPriority(Thread.MAX_PRIORITY); thread3.start();

Do the first of the things to do of part 1.1 (see page 3) again but using the modified program this time.

Compare your results with those that you got the first time.

Things to try part 2:

When you’ve run the program above write a paragraph that explains what you see in terms of what you’ve learned in lectures about (a) buffers, (b) multiprocessing/multithreading (c) the producer-consumer problem. Things to try part 3:

1. Run the above program, experimenting with different sleep times, than 100ms. Try, for example, 1ms, 20ms, 50ms, 200 ms, 300ms. The higher the time is in ms, the slower the number will appear in the counter.

2. Now that you’ve run the program, can you see clearly (not from the code but simply from what you observe when running it) why this program, simple though it is, cannot be implemented with only one thread. Explain.

3. Now eliminate both the try block and the catch block so that the inside of the while block just looks like:

counterWindow.setText("" + count); count++; if(count > 10) { count=1;


}

After modification, run the program again and explain what you see.

Things to try part 4

Consider the following software:

RunnableJob.java package com.cakes; public class RunnableJob implements Runnable { @Override public void run() { Thread thread = Thread.currentThread(); System.out.println("RunnableJob is being run by " + thread.getName() + " (" + thread.getId() + ")"); } }

ThreadExample.java package com.cakes; public class ThreadExample { public static void main(String[] args) throws InterruptedException { RunnableJob runnableJob = new RunnableJob(); Thread thread1 = new Thread(runnableJob); thread1.setName("thread1"); thread1.start(); Thread thread2 = new Thread(runnableJob, "thread2"); thread2.start(); Thread thread3 = new Thread(runnableJob); thread3.start(); Thread currentThread = Thread.currentThread(); System.out.println("Main thread: " + currentThread.getName() + "(" + currentThread.getId() + ")"); }


}

Edit the software above and instead of using getName() and getID() use: thread = Thread.currentThread(); System.out.println(thread); The last line will make thread use the Thread class's toString method Write down what you see.


Practical 11

Things to do: 1. In two distinctly different ways edit the line of code above, i.e. dir | where-object {$_.Length –gt 100}

so as to give a directory listing of those files whose length is greater than 100 bytes but less than 200 bytes. 2. Is dir the native command in PowerShell for getting a directory listing. If not what is the native command? Get-ChildItem

3. Write out all the ways of getting directory listings in PowerShell, explaining by whom or in what context the different ways are likely to be used. (You may have to read over previous practicals to answer this.) Dir Ls

Things to do: 4.

Find out, by using different values of the numerical parameter, what the following useful line of PowerShell does: dir | where-object {$_.LastWriteTime –lt (get-date).addmonths(-6)}

It displays the last write time of the files. So by changing the parameter to say “-1000” you may not get any results since there was no file wrote then.

Things to do:

5. There is another way of single stepping through a script, using F10. Find out and explain what F10 does, comparing it with F11. F10 allows you to go through the code line by line where as with f11 it goes to the actual function the script is carrying out.


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.