Chapter 10 Flashcards

1
Q

What does a threads run method do?

A

Executes when the thread acquires the CPU

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Time slicing

A

-A means of scheduling threads or processes wherein each process receives a definite amount of CPU time before returning to the ready queue
-aka timing-out- running thread times out automatically, pausing the running thread’s execution and sending to rear of the ready queue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Synchronization problem

A

-a type of problem arising from the execution of threads or processes that share memory
-the consumer can access data that are not there, can miss data, and can access same data more than once

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A sleeping thread vs a waiting thread

A

Sleep- can be put to sleep for a given number of milliseconds. When the thread wakes, it goes to rear of ready queue

Wait- it voluntarily relinquish the CPU to wait for some condition to become true. Thread can be notified when condition becomes true and move again to rear of rear queue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Readers/writers vs producer/consumer

A

unlike p/d, r/w may access the shared data in any order and there may be multiple readers and writers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How would you make the Student class from ch. 9 thread safe for readers and writers?

A

Student class consists of multiple get methods (read) and one set method (write). The key to making it
thread-safe is by accessing the student objects through a SharedClass object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What role do ports and IP addresses play in a client/server program?

A

IP address is a unique identifier of a
computer unique identifier of a computer on a network. Port is the object (channel) via which clients
connect object (channel) via which clients connect to the server.

Both are used in a client/server program as arguments for a
Socket’s method connect which is used to connect the socket to a host
computer (server) on given IP address and port specified for it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a local host and how is it used to develop networked applications?

A

It’s a standalone computer that may or may not be connected to the internet

The localhost is a hostname (IP name) of the current computer and it is widely recognized standard.

Developers tend to use it as a test
environment for their applications
before making them public. It uses a
loopback mechanism - it is basically sending all requests back to itself.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Why is it a good idea for a server to create threads to handle clients requests?

A
  1. It makes the design of each task simpler
  2. Processes of separate threads can run concurrently, giving clients timely access to the server
How well did you know this?
1
Not at all
2
3
4
5
Perfectly