Click here to Skip to main content
15,899,026 members
Articles
Article
(untagged)

Live Objects - Part I

Rate me:
Please Sign up or sign in to vote.
1.16/5 (11 votes)
7 Dec 20054 min read 35.6K   8   11
Why thread-libraries are insufficient... from a design perspective

This article explains the unsuitability (from a design point of view) of using thread libraries for implementing multithreaded systems. Please do provide me with your comments and suggestions to improve this article - areas that need further clarification, errors/omissions.

1 INTRODUCTION

 
Abstraction and encapsulation are key to managing complexity. Objects provide good abstraction by, among other things, modeling reality. However, a crucial part of reality that is not represented adequately in an object is a sense of time. Objects exist in time and space, and interact with other objects to do things; they have "life".
 
Spatial representation, OK.
Temporal representation, not OK.
 
A mechanism for intuitively expressing the idea of a Live Object* (or Active Object), is inadequately supported by the threading libraries of object-oriented languages today. Threading libraries hide very little of the complexity involved in the use of threads.  
 
Many, if not most, non-trivial applications are multithreaded. Often, the focus and the major obstacles in implementing a multithreaded system are the low-level details of threading, rather than the problems that the system is designed to solve.
 
*Live Object makes for a better acronym (LOOP) than Active Object (AOOP??). It can also be interpreted as the imperative "Live! Object." :-)

2 CURRENT THREADING MECHANISMS

Presently to use threads, we create a thread and give it sections of code (from the object possibly) for it to do. For example,

threadHandle=CreateThread(StuffToDo , OS/LibraryParameters)

is how threads of control are created from a program. The code (StuffToDo) is then executed in the newly created thread.
 
In the present library implementations,

2.1 Threads use objects.

Threads use the code from objects to be more precise. The thread executes the function that we specify. In the example, StuffToDo could be the method of an object.

2.2 Threads are to functions what objects are to classes.

Or, threads are objects. The thread object instantiates a function, brings into execution-space so to say, executing it. The library makes the thread a first-class "object" in the program-space. It has a handle, threadHandle, that can be used to refer to it.

2.3 Threads are almost equivalent to operating system threads.

Most of what can be done with an operating system thread can be done with library threads also - one can suspend a thread, resume it, abort it etc.
 

3 'OBJECT'IONS - CRITIQUE

3.1 Unnatural modeling

In the real world, entities use their time and their resources to do things. Abstractly, a thread can be viewed as a flow of time. In the library-model, threads use objects (Refer 2.1) whereas in the real-world, objects use threads. This inappropriate modeling contributes to the difficulties of conceptualizing and implementing threaded systems.

 It should be
"Objects use threads",
not "Threads use objects".

3.2 Dubious Relevance of Thread Objects In Program-Space

An object oriented program/system is an exchange of messages between objects resulting in side-effects useful towards the solution of the problem at hand. Thread objects (Refer 2.2) are, in their current avatars, only a way of calling a function; they do not help to manage complexity. Instead, thread object interactions intrude on the main logic of the program.

Hide the complexity of threads
from the programmer, effectively.

3.3 Abstraction Leakage

Why have thread objects at all in programs? Threads are very much operating system entities (Refer 2.3), but are they really required at the abstraction level of the program? If we have thread objects in the program, it is only natural that they have methods and behaviours similar to the real-world (albeit on the OS-side) entities that they model, with some high-level constructs thrown in for good measure. If we have thread objects, the programmer will necessarily be exposed to their complexity as well. So much for abstraction and encapsulation!

For operating systems, threads are expensive to manage. The objection to live objects that is raised all too often is: "What! If I have a 1000 live objects, it would mean 1000 threads too? You must be out of your mind..." . This mental block must be removed. The programming language back-end, the popular idiom of the runtime, could possibly be adapted to meet the external implementation constraints/limits.

Eliminate threads from
the programmer's vocabulary.


4 CONCLUSION

The language should help people to take their minds off low-level threading details and focus on more domain-relevant issues at hand, enabling the construction of more useful programs.

- Thomas Jay Cubb
http://oozone.blogspot.com/
  

 
 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
India India
Choose your poison! My blogs
Thoughts - http://incubbator.blogspot.com
Literary - http://cubbspace.blogspot.com
Trivia - http://oraclique.blogspot.com
Computing - http://oozone.blogspot.com

Comments and Discussions

 
Generalan implementation of LOOP Pin
osy9-Dec-05 0:40
osy9-Dec-05 0:40 
GeneralThe reason for a low score Pin
David O'Neil7-Dec-05 18:17
professionalDavid O'Neil7-Dec-05 18:17 
This article gets my '1' for the following reason: You have not exhibited a fundamental understanding of threads in your article. You may understand threads, but your article does not transfer ANY of the understanding you may have. (It is doubtful that you do have the understanding, based upon this article.)

You seem to be discussing threads and threading libraries interchangeably, and that is confusing in itself. You also make the comment: "Threads use objects". Actually, in a well designed system, objects use threads. You could also make the statement that 'threads manipulate objects'. There is a HUGE difference between your statement and those statements.

Another bad quote: Threads are to functions what objects are to classes. As a class is a (direct code) representation of an object, a thread would therefore be a function, according to your statement. This is blatently false.

Another quote: "Threads are almost equivalent to operating system threads". As most theading libs are just wrappers around operating system threads, you should just throw every statement you make concerning this point directly into the trash. Threads created by a vast majority of threading libs ARE OS threads. The library might not give access to all the OS thread functions, but that is irrelevant.

And yet another quote: "A thread can be viewed as a flow of time for practical purposes". This statement shows a total lack of understanding of threads (or at the minimum, a total lack of communication skills). A thread can best be viewed as a sub-process of an object, in most cases. This has VERY LITTLE to do with 'a flow of time', except that the thread gets executed in time.

Another quote: "..thread object interactions add complexity and intrude on the main logic of the program". If you have ever really needed a thread, you would know that THREADS CAN VASTLY REDUCE PROGRAM COMPLEXITY, and will introduce a lot less complexity than making code that single-tasks and checks during each iteration to determine whether to execute the equivalent of a thread.

"In the scenario of single-threaded program development, come to think of it, the programmer plays the role of the thread object during coding". This is a crappy sentence, through and through. You weren't discussing single-threaded applications prior to this, and single-threaded apps have almost nothing to do with the premise of your article. Your article seems to be stating that LOOP is a better alternative than multi-threading. Everything in that paragraph should be scrapped, or your entire article should be rewritten to present a more cohesive point.

Everything below that paragraph needs thrown out, or rewritten (as well as everything above it). Why have threads? Because they solve a major problem with programming. Are threads really that expensive for Windows or Linux or Unix to manage? Task Manager currently shows 44 processes running on my system. It says I have 498 threads running. Does this bother me? No, because the OS handles them so quickly that I don't even suspect they are running.

Your OOTOPIA section presents code without any discussion of how the addition of LOOP will really improve the functioning of the underlying program. In fact, it is easy to visualize a huge system decrease in performance if such a system is put in place, because you must then install some type of system to ensure proper TIME sequencing of the objects, and this WILL NOT be a trivial task when the number of threads is significant.

Your intro states: "However, a crucial part of reality that is not represented adequately in an object is a sense of time". The LOOP system will probably suffer just because it will be necessary to implement a time sequencing system between objects. I would rather use the current system, which seems to be efficient (remember: 498 threads!), rather than a system that will impose the additional overhead for time sequencing that will be needed by the LOOP system (even though the 498 threads would not be directly translatable into LOOP threads, so my example is somewhat off).

In short, your conclusion that "A LOOP (Live Object Oriented Programming) language is the need of the hour" is completely unsupported by your article.

If you want to discuss Eckel's statements in your article, do so in the article, not by having a free-standing reference. (You do not show ANY tie between some of the articles in your External Links section, and your own article.)

I hope this feedback gives you the info to make an article that says something that you really mean to say, rather than the article you have presented here. Or just delete the article. As it stands, it does't give newbies anything useful for their arsenal, and just makes more experienced programmers go "Huh?"

Good bye.
David
GeneralRe: The reason for a low score Pin
sonofdelphi7-Dec-05 20:05
sonofdelphi7-Dec-05 20:05 
GeneralRe: The reason for a low score Pin
David O'Neil8-Dec-05 4:28
professionalDavid O'Neil8-Dec-05 4:28 
GeneralRe: The reason for a low score Pin
sonofdelphi8-Dec-05 17:20
sonofdelphi8-Dec-05 17:20 
GeneralLive objects have no concurrency Pin
Shao Voon Wong7-Dec-05 14:43
mvaShao Voon Wong7-Dec-05 14:43 
GeneralRe: Live objects have no concurrency Pin
sonofdelphi7-Dec-05 17:38
sonofdelphi7-Dec-05 17:38 
GeneralHide the complexity of threads from the programmer, effectively. Pin
balazs_hideghety7-Dec-05 3:52
balazs_hideghety7-Dec-05 3:52 
GeneralRe: Hide the complexity of threads from the programmer, effectively. Pin
sonofdelphi7-Dec-05 17:02
sonofdelphi7-Dec-05 17:02 
GeneralRe: Hide the complexity of threads from the programmer, effectively. Pin
balazs_hideghety8-Dec-05 0:41
balazs_hideghety8-Dec-05 0:41 
GeneralRe: Hide the complexity of threads from the programmer, effectively. Pin
sonofdelphi8-Dec-05 17:33
sonofdelphi8-Dec-05 17:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.