CSC 216/s08/but one lamp: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(11 intermediate revisions by 3 users not shown)
Line 2: Line 2:
[http://meta.wikimedia.org/wiki/Help:Wikitext_examples Formatting Help Guide from MetaWiki]
[http://meta.wikimedia.org/wiki/Help:Wikitext_examples Formatting Help Guide from MetaWiki]


==Place Title of Exercise Here==
==An Introduction to Threads==


Give the title of your exercise, which may include the name of the topic you are covering, or some other catchy title.
This project will introduce threads to students who have no previous knowledge on the subject.


===ONE BUTT LAMP===
===What are Threads?===


===The problem===
Threads are a way to break up your machine's processing so it can do many tasks all at the same time. These tasks are able to share variables, monitor each other’s progress, and begin and terminate separately.


Describe what you are attempting to teach students by this exercise.
===Participants and props===
 
For this too work, six students with a healthy desire for competition must be chosen from the class.
 
The only required materials are two decks of playing cards, eight note cards, and a table to sit around.


===Participants and props===
==How it works==


How many students will participate?  What else do you need (e.g., old tennis ball, Powerpoint slides, software).
===Table Setup===
[[Image:VectorArrayPic.jpg]]<br>
Each team should have four square "variables" or note cards, that represent either an Array or Vector.(Depending on previous knowledge and/or whether or not array resizing should be incorporated into the exercise) These Vectors are normal instance variables for the single student team. For the 5 student team, the Vectors are instance variables of the Driver and therefore shared variables amongs the threads.


===The script===
===Game Summary===
First the teacher should get out two decks of cards, remove the jokers, and shuffle well. He should then get a single volunteer from the class and hand him one of the decks. Next, the teacher should find five more students ready to compete against the other student giving one of the other students the second deck. The teacher will instruct the single student that when he says go, that student should sort the card into suite and then order each suite from 2 to Ace. He will then instruct the group of five that when he says go, the student with the deck, the Driver, should count out exactly thirteen cards and give it to one of his fellow students, a thread. He should repeat until all the cards are given out. As soon as a thread gets a deck it may begin to sort it into each suite by placing a card in it's coresponding vector. A thread may not pick up any cards unless handed it by the driver. It may, however, begin it's task as soon as it receives cards without having to wait on another thread to be initialized. Once all threads have terminated the suite sort, the driver must then give each thread a stack (suite) to sort from 2 to Ace. The group of five people should finish much faster than the single person.


Describe how to do your exercise.
This simulation should show that by breaking up processing in this way, threads can accomplish a task faster than a single thread. The teacher should then go on to teach some of the more intricacies of threads.

Latest revision as of 20:40, 15 April 2008

Formatting Resources

Formatting Help Guide from MetaWiki

An Introduction to Threads

This project will introduce threads to students who have no previous knowledge on the subject.

What are Threads?

Threads are a way to break up your machine's processing so it can do many tasks all at the same time. These tasks are able to share variables, monitor each other’s progress, and begin and terminate separately.

Participants and props

For this too work, six students with a healthy desire for competition must be chosen from the class.

The only required materials are two decks of playing cards, eight note cards, and a table to sit around.

How it works

Table Setup


Each team should have four square "variables" or note cards, that represent either an Array or Vector.(Depending on previous knowledge and/or whether or not array resizing should be incorporated into the exercise) These Vectors are normal instance variables for the single student team. For the 5 student team, the Vectors are instance variables of the Driver and therefore shared variables amongs the threads.

Game Summary

First the teacher should get out two decks of cards, remove the jokers, and shuffle well. He should then get a single volunteer from the class and hand him one of the decks. Next, the teacher should find five more students ready to compete against the other student giving one of the other students the second deck. The teacher will instruct the single student that when he says go, that student should sort the card into suite and then order each suite from 2 to Ace. He will then instruct the group of five that when he says go, the student with the deck, the Driver, should count out exactly thirteen cards and give it to one of his fellow students, a thread. He should repeat until all the cards are given out. As soon as a thread gets a deck it may begin to sort it into each suite by placing a card in it's coresponding vector. A thread may not pick up any cards unless handed it by the driver. It may, however, begin it's task as soon as it receives cards without having to wait on another thread to be initialized. Once all threads have terminated the suite sort, the driver must then give each thread a stack (suite) to sort from 2 to Ace. The group of five people should finish much faster than the single person.

This simulation should show that by breaking up processing in this way, threads can accomplish a task faster than a single thread. The teacher should then go on to teach some of the more intricacies of threads.