Tuesday, 18 November 2008
Common Errors in C
Sunday, 2 November 2008
Java Workqueue API
- executors
- queues
- concurrent collections
- synchronizers
- atomic (in package: java.util.concurrent.atomic )
- locks (in package: java.util.concurrent.locks )
Executors
Executors are containers taking care of the execution of tasks, just as SwingUtilities used to do it. Different kinds of executors are imaginable:- DirectExecutor (performing the task but not asynchronously)
- ThreadPerTaskExecutor (one thread is created for each task to be performed)
- SerialExecutor (each task is performed sequentially)
- ThreadPoolExecutor (executor performing using a pool of threads)
- ScheduledThreadPoolExecutor (executor performing using a pool of threads at certain specified moments or periodically)
Queues
Another useful data structure for performing task in parallel and asynchronously are queues (also known as FIFO data structures). The java.util.concurrent package provides a number of data structures for this purpose too. One particular kind of FIFO are blocking queues, for which five different versions exist:- LinkedBlockingQueue
- ArrayBlockingQueue
- SynchronousQueue
- PriorityBlockingQueue
- DelayQueue
Synchronizers
A number of possible techniques can be used to synchronize threads. Among these are semaphores which we discussed in the linux kernel context. Other types provided by the java.util.concurrent package, such as the CountDownLatch, used to block some actions until a number of events or elements have been counted, the CyclicBarrier, which is a resettable multiway synchronization mechanism, an exchanger to allow threads to exchange objects at some definite point and the already mentioned locks.Concurrent Collections
The java.util Collection Framework already contained a number of snychronized or synchronizable classes. However, the java.util.concurrent package introduces new structures useful in a multithreaded context:- ConcurrentHashMap,
- ConcurrentSkipListMap,
- ConcurrentSkipListSet,
- CopyOnWriteArrayList, and
- CopyOnWriteArraySet
Timing Units
The java.util.concurrent package also introduces a new class TimingUnit to provide different kind of granularity as to which unit of interval for time measurements should be used. Here again, it would be useful to take a look at the implementation of the kernel and compare.Atomic and Locks
Since atomic variables and locks are in other packages, I will describe them in other entries. However, it is again interesting to note that the same topics were already discussed in other entries of this blog.Flash with Flex
So I tried a few things with Flash now that I more or less know the basics of flex (and only the basics).
So I wrote my first little movie in flash and compiled it using flex's compiler.
I can not really do an introduction yet to flash and flex. I still need to get use to too many things. For example, I am not really happy not knowing which data structures are available in action script. Maybe I have been spoiled by java using the java.util collections. Yet I think it sensible to expect the existence of a number of standard libraries one can use to prevent the inventingthewheelitis.
One thing I found at least im internet is from a developer from Mannheim who wrote some data structures for games in action script. I will have to take a look at it. It sure sounds really interesting.
I have also been interested in what is the best way to create small movies for fun. So I just thought of the general object oriented structure of my character creations. Actually I already had some project of the sort in java. But I had not that much because other priorities popped up as they always do.
Oprofile - What are thou ?
O.K Apart from doing stupid references to films I actually have not really liked. What am I doing?
After reading a few mails from the Linux Kernel Mailing list, I found the following tool which seems useful: oprofile. I must admit I still do not have a clear idea of all the possibilities that this tool offers.
The first thing to know it is a profiler and it is a profiler capable of giving a number of information on a program with quite a low overhead. But what is a profiler?
A profiler collects information on running processes of a computer to analyze the performance of a program (see the wikipedia article on performance analysis).
It gives the possibility to look at the following aspects of a system:
- Call-graphs (i.e it looks at the graph of the functions calls of programs)
- libraries used by a program
- instruction level information collections (also on assembly code level)