Table of Contents
DOWNLOAD.COM: List Your BeOS Applications Did you know that you can list your BeOS applications for FREE on Download.com? Download.com, http://www.download.com, is a popular online software library which lists freeware, shareware, and trial versions of commercial software for various platforms including the BeOS. They are mirrored by CNET.com, Gamecenter.com, Builder.com, Snap!, and Netscape's Netcenter. Due to rising demand for BeOS applications, Download.com is considering adding a BeOS-exclusive download area to their site. Currently, only Windows, Mac OS, Palm OS and Windows CE enjoy this distinction. However, in order to make the new BeOS area a reality, Download.com needs lots and lots of BeOS applications! (Currently, there are about 100 BeOS applications available through Download.com. You can search for all BeOS apps listed on Download.com and its mirrors by using the keyword "bewareos.") Your app may already be there, but chances are the listing needs updating. What do you get when you submit your app to Download.com? Well, in addition to exposure on several high-traffic web sites, Download.com provides a detail page for each application you submit. This page includes a description of your product and system requirements, as well as links to online stores where the product can be purchased, download URLs, and additional information. If you agree to promote a new release or a major upgrade of your software exclusively through Download.com, you can ask to participate in the Premier Program which entitles you to an extended product description, file hosting for a short time, a Download.com newsletter review, a front page highlight, and a category front page highlight. All for free! To submit an application to Download.com, follow these easy steps:
Note: In the Submission form, currently there is no R4
option under the " Note also that Download.com does not host files, except in the case of Premier applications. You will need to provide them with a download URL. Happily, on the same page as the submissions form, they suggest a number of online archives that will host your application for free. If you'd like more information about submitting your application to Download.com, contact Kerry Parker at kerryp@cnet.com. She is in charge of BeOS title listings for Download.com. And if you do contact Kerry, please be sure to thank her for her time and energy, since she is the driving force behind adding a BeOS-exclusive area to the Download.com site!
A new site has been started that focuses on BeOS audio, and provides resources for audio pros and hobbiests who are working in Be audio or would like to. . . It's called "le BUZZ," and is located at http://home.beoscentral.com/lebuzz There are Be audio headlines, a "ClickList" page of Be audio users who are willing to help each other directly through e-mail, and a Be audio message board called "Le BuzzBoard." Given the recent profile audio has been given by announcements at Be, this site has arrived at a good time!
BE ENGINEERING INSIGHTS: Abusing Multithreading By Cyril Meurillon - cyril@be.com
We've been telling you since the beginning that threads are neat and wonderful. A number of Newsletter articles have been written on how to increase parallelism in your applications by creating more threads and synchronizing them. Here are a few of those articles:
All this is good, but it helped create the impression that programmers who spawn more threads are smarter than others. This perhaps led to some abuse and excess, with what appears to be a contest between some programmers for who will spawn the most threads. This doesn't really come as a surprise. Since multithreading is a relatively new programming model, some abuse is to be expected. Abuse -- or excessive use -- of multithreading can cause a number of problems. First, threads are not free. It's true that they are lightweight. A BeOS thread is not as heavyweight as a typical UNIX process -- for example, the address space and file descriptors are shared between teams. But they do use up precious system resources: memory, semaphores, etc. For a start, each thread has a stack, which has to be allocated and consumes memory. How much memory? It depends on the thread, as stack pages are allocated on demand. But worse is the fact that the kernel stack -- the part of the stack which is used when the thread runs in the kernel -- has to be preallocated and locked down in memory -- it can't be paged out to disk. This is about 32K of memory per thread that you can kiss goodbye. In addition, there are kernel structures used to keep the thread state, some of them stored in locked memory as well. As a result, 20 threads eat up approximately 1M of memory. That's a lot. Perhaps you don't care: you are writing an application targeted to high-end users with plenty of memory. And you're telling me that memory is cheap these days anyway. I could argue that this approach tends to make systems fatter and slower. But I have something more important to warn you about. By creating more threads and having to synchronize them, you greatly increase the risks of deadlocks. That risk does not increase linearly with the number of threads, but with the number of possible interactions between threads -- which grows much faster. Since I'm discussing interactions between threads, it might be useful to distinguish between different kinds of multithreading. Regular MultithreadingThe threads are executing the same code on different data, and there is very little interaction between them. Typically, applications dealing with computations that can be easily parallelized, as on images, resort to this technique. Servers can also fire a thread for every client request, if the request is complex enough. For this type of multithreading, synchronization between the different threads is usually quite basic: the control thread fires all the computing threads and waits for them to complete. Irregular MultithreadingThe threads interact in a complex manner. Each thread can be seen as an active agent that processes data and sends messages to other agents. Media Server nodes are an example of such an organization. Synchronization is usually complex. It can be of the producer-consumer type, using ports. Or it can be customized, based on basic tools like semaphores or shared memory. It is clearly not a universal classification. Just a simple way to look at multithreading from the standpoint of interaction complexity. With regular multithreading, adding threads does not add to the overall complexity of the application, because the additional threads don't interact between themselves. On the other hand, adding threads in the context of irregular multithreading increases complexity because the additional threads do interact between themselves. My warning about the increased risk of deadlock clearly only concerns applications that use irregular multithreading. The risk of deadlock is high, and quickly gets beyond anybody's comprehension as the number of threads involved becomes larger than just a few. These deadlocks are usually non-trivial, and it might prove useful to review some of the classic scenarios:
I remember my initial experience of C++, and I can't help thinking of developers confronting multithreading for the first time. My first reaction to C++ was enthusiasm. I was very excited about seemingly neat features like operator overloading and multiple inheritance. I used it and abused it. What had to happen happened: I got trapped a number of times by subtleties I did not grasp in the first place, many of them being undocumented or compiler dependent. I almost became disillusioned from getting burned so many times. But eventually, I got a good sense of balance, knowing where to stop the house of cards I was building. It's the same with multithreading: I believe all developers go through the same phases of excitement, disillusion and eventually wisdom. I can only recommend the greatest precautions when designing multithreaded applications. It's tempting to push multithreading to its limits, using a lot of threads that interact in complex ways. But it's always better to start with an architecture you fully comprehend.
BE ENGINEERING INSIGHTS: Using Archived Interface Objects By Jean-Baptiste Queru - jbq@be.com
Many developers ask how to archive interface objects and reuse them later. There are several reasons why you'd want to do that -- here are the main ones:
That's enough marketing talk -- this is "Engineering Insights" after all. Let's see what has to be engineered -- and here's the good news -- there's nothing you have to do, or, more accurately, very little. Take a look at this example: ftp://ftp.be.com/pub/samples/interface_kit/archint.zip It comes with a Now let's see the magic code, in The first part loads a BMessage* ReadMessageFromResource(int32 id) { app_info ai; BFile f; BResources r; size_t res_size; const void* res_addr; BMessage* msg=new BMessage; if ((be_app->GetAppInfo(&ai)!=B_OK) ||(f.SetTo(&ai.ref,B_READ_ONLY)!=B_OK) ||(r.SetTo(&f)!=B_OK) ||((res_addr=r.LoadResource(B_MESSAGE_TYPE,id,&res_size))==NULL) ||(msg->Unflatten((const char*)res_addr)!=B_OK)) { delete msg; return NULL; } return msg; } The second part creates the window from the AWindow::AWindow(BMessage* m):BWindow(m) { atomic_add(&numwindows,1); numclicks=m->FindInt32("clicks"); Show(); } As you can see, there's nothing difficult here. You just
call the base class constructor and extract any extra data
you might have stored in the This last part shows why custom void AWindow::MessageReceived(BMessage* m) { switch(m->what) { case 'colr' : { // removed for clarity break; } case 'dump' : { DumpArchive(); break; } case 'clon' : { CloneWindow(); break; } default: BWindow::MessageReceived(m); break; } } void AWindow::NewColor(rgb_color col) { BView* v=FindView("colorview"); if (v!=NULL) { v->SetViewColor(col); v->Invalidate(); } } The trick is that the default target for a Now let's look at some drawbacks of using archived interface objects:
DEVELOPERS' WORKSHOP: Getting Ahead of Ourselves - Playing Movies With the New Media Kit By Eric Shepherd - sheppy@be.com "Developers' Workshop" is a weekly feature that provides
answers to our developers' questions, or topic requests.
To submit a question, visit
[http://www.be.com/developers/suggestion_box.html].
This is the first in a series of articles about programming
with the new Media Kit. Soon there will be Media Kit add-ons available that provide
support for various video file formats. This week, let's
take a look at how to play back a movie using the new Media
Kit and these add-ons. You can download the code for this project at
ftp://ftp.be.com/pub/samples/media_kit/simplemovie.zip. It
consists of three C++ source files and two header files. The All it has to do is instantiate a The This is done by calling the If the Now we get to the meaty, "we've been waiting for this for
two months" part: the The MediaPlayer constructor's job is to find an appropriate
node to process the movie file and instantiate a copy of the
node to be used to actually perform the playback. It sets
playingFlag to false (we use this flag to keep track of
whether or not the movie is playing), and obtains a
This static call in the Then it's necessary to identify a node that can handle the
movie file that the user specified. This is done by calling
Note that errors are stashed in a member variable called
initStatus; the Once an appropriate add-on has been identified and
information about it stashed in nodeInfo, a node needs to be
instantiated from that add-on. Nodes located in media
add-ons are referred to as "dormant nodes." We call
Since the media_node mediaFileNode is a file handling node,
we next have to tell the node what file to handle, by
calling This sets up the Now that the file node has been instantiated, it's time to
instantiate the other nodes needed to play back a movie. The
Next, a time source is needed. A time source is a node that
can be used to synchronize other nodes. By default, nodes
are slaved to the system time source, which is the
computer's internal clock. However, this time source, while
very precise, isn't good for synchronizing media data, since
its concept of time has nothing to do with actual media
being performed. For this reason, you typically will want to
change nodes' time sources to the preferred time source. We
get that using the following code: The first call obtains a media_node representing the
preferred time source to which we'll slave our other nodes.
The second call, to You can think of a media node (represented by the media_node
structure) as a component in a home theater system. It has
inputs for audio and video (possibly multiple inputs for
each), and outputs to pass that audio and video along to
other components in the system. To use the component, you
have to connect wires from the outputs of some other
components into the component's inputs, and the outputs into
the inputs of other components. The Media Kit works the same way. We need to locate audio
outputs from the We only want a single audio connection between the two nodes
(a single connection can carry stereo sound), and the
connection is of type We likewise have to find a video output from the
The problem we have now is that the We need to locate a codec node that can handle the video
format being output by the This call to Note that in real life you should ask for several nodes, and
search through them, looking at the formats until you find
one that best meets your needs. Then we use Now we're ready to start connecting these nodes. If we were
setting up a home theater system, right about now we'd be
getting rug burns on our knees and skinned knuckles on our
hands, trying to reach behind the entertainment center to
run wires. The Media Kit is way easier than that, and
doesn't involve salespeople telling you to get expensive
gold-plated cables. We begin by connecting the file node's video output to the
codec's input: You may wonder what's up with the Next it's necessary to connect the codec to the video output
node. This begins by setting up Now we connect the audio from the media file to the audio
mixer node. We just copy the media_format from the file's
audio output, since both ends of the connection should
exactly match. The last step of configuring the connections is to ensure
that all the nodes are slaved to the preferred time source: The The Then we simply call And we set Notice that we don't start the audio mixer node ( The The " The Here we obtain the current performance time by taking the
real time and passing it through Last, but not least, let's look at the This code makes sure playback is stopped (disconnecting
currently playing nodes is discouraged), then disconnects
each of the three connections we established in Hopefully this sample code will be helpful in learning to
write software that uses the new Media Kit for playback of
media data. Updates to the Media Kit chapter of the Be Book
are coming over the next few weeks (a large
Last week's column, "Another Bedtime Story"
What we have today with Explorer and Windows is what I'd
call tentacular integration. (I won't say here what the
spellchecker on my diminutive Toshiba Libretto offers as an
alternative for tentacular, a word it pretends not to know.
It is in the American Heritage Dictionary and my Libretto
will run the BeOS once we get Toshiba to release the specs
of their sound chip.) There is a single word for Explorer, but the software itself
has many tentacles that reach deep inside the system. As a
result, Microsoft seems to be saying, a lot of damage will
occur if you forcibly remove Explorer. Specifically, when
the now famous "Felten program" attempted to remove
Explorer, Microsoft wanted to show how Web access and
navigation were still possible, if you knew your way around
Windows Registry, where a myriad of settings are stored.
Explorer was so tightly integrated with Windows that one
couldn't really remove it, just hide and disable it. Furthermore, as a result of this failed "Explorer-ectomy,"
performance suffered greatly. Sorry about that, said
Microsoft, it's an imperfect world, but through our efforts
consumers benefit from tight integration. I won't add to the sum of ironies provoked by the videotapes
that tried to persuade the courts of justice and public
opinion of the soundness of this argument. Thinking of
Redmond's serene and understated culture, one can imagine
the sharing of thoughts following the discovery of
unfortunate editing miscues. But if, as Microsoft contends, Explorer is not a separate
application so much as an operating system upgrade -- hence
its size, depth, and complexity -- one might be tempted to
explore that line of reasoning. That is, the Web is
important and is now tightly woven into our everyday lives.
Certainly, a mere application cannot do justice to such an
important and pervasive function. That responsibility
belongs to the platform, to the operating system. Perhaps. But couldn't one make a similar argument about word
processing, spreadsheets, or presentations? Shouldn't these
important functions also be integrated into the operating
system? Come to think of it, if Microsoft Office isn't
integrated with Windows, it comes pretty close for millions
of users who receive Office as a bundled, if not integrated,
product. The technical argument that one must "integrate"
Explorer, while one can merely "bundle" Office doesn't
withstand technical scrutiny. Take two identical PCs loaded
with a late version of Windows 95, OSR 2.1, or later.
Install (integrate if you prefer) Explorer on one and
Navigator on the other, and compare performance. There's no
significant difference. If one reads carefully through Mr. Allchin's deposition and
the language used in various video demonstrations, one sees
the words "rich" and "richness" used to describe the
improved user experience that results from making elements
of the user interface more Web-like. This poses another
question regarding the "how" of integrating Web capabilities
inside the operating system. To oversimplify a bit, couldn't
Microsoft have broken the job in two pieces -- a system
module and an application module? This approach would make
removing the application module a simple and safe task. It
would also make installing another browser -- while
preserving the "richness" afforded to other applications by
the system module -- easier. One might ask whether Microsoft
had non-technical motives in choosing a tentacular
implementation instead of the modular one. Lastly, in reading the court transcript, Microsoft seems to
allege that the BeOS NetPositive browser is "integrated,"
and cites the help system as proof. If you trash
NetPositive, a simple operation, the help system no longer
works: it needs a now absent HTML interpreter. Ergo,
NetPositive is integrated. Assume for a moment that the help system is written in the
format of an editor supplied with the OS. If you delete the
editor, you can no longer read the help files. Unless, of
course, you use a third-party editor. Does this mean that
the supplied editor is integrated with the OS? Of course
not. And what will Microsoft say when one or more of the
third-party browsers currently under development for the
BeOS become available and read the help file or the BeOS
documentation -- even if NetPositive is missing? Will that
make them -- ipso facto -- integrated with the BeOS?
1997 Be Newsletters | 1995 & 1996 Be Newsletters Copyright ©1999 Be, Inc. Be is a registered trademark, and BeOS, BeBox, BeWare, GeekPort, the Be logo and the BeOS logo are trademarks of Be, Inc. All other trademarks mentioned are the property of their respective owners. |