Posts Tagged linux

Lightspark gets video streaming

Just a brief news. It’s been a long way, and today I’m very proud to announce video stream­ing sup­port for Lightspark, the effi­cient open source flash player. More­over, per­for­mance looks very promis­ing, I’m not going to pub­lish any results right now as I’d like to do some test­ing before. Any­way, Lightspark seems to be out­per­form­ing Adobe’s player by a good extent, at least on linux.

In the next post I’ll talk a bit about some per­for­mance tricks that made it pos­si­ble to reach such result.

, , , ,

1 Comment

Allocating aligned memory

Just a quick note that may be use­ful to some­one else. As you may know SSE2 intro­duced a new instruc­tion: MOVDQA (MOVe Dou­ble Quad­word Aligned). This is used to move 128 bit (16 bytes) of data from/to memory/xmm reg­is­ters. This instruc­tion only works if the data is aligned the the 16 byte bound­ary. There is also another instruc­tion for the unaligned case, but the aligned ver­sion is way faster. So let’s sum­ma­rize some tech­niques to get an aligned mem­ory area

  • For local, sta­tic and mem­ber vari­ables you can append __attribute__ (( aligned (16 ) ) to the type def­i­n­i­tion. Example:
  • struct A { int val; } __attribute__ ((aligned ( 16 ) );

  • For dynam­i­cally allo­cated mem­ory the usual mal­loc is not enough, but there is a posix_memalign which has the seman­tics that we need. It is defined as:
  • int posix_memalign(void **memptr, size_t alignment, size_t size);

So we have to pass a pointer to the pointer that will receive the newly allo­cated mem­ory, the required align­ment (which has to be a power of two) and the allo­ca­tion size. Mem­ory allo­cated this way can (at least on the glibc imple­men­ta­tion) be freed using the usual free func­tion.

, , , , , ,

No Comments

Dual boot, the clean Debian way

Just a lit­tle trick I’ve found while installing Win­dows Vista on a Debian pow­ered pc. If you want Grub2 to find and con­fig­ure dual boot automag­i­cally, just install the pack­age os-prober.

The update-grub com­mand will now take care of  your  oper­at­ing sys­tem pan­theon for you.

, , , ,

No Comments

Picking windows

The Win­dow Picker Applet is an GNOME applet (devel­oped at Canon­i­cal) that dis­plays the list of  run­ning appli­ca­tions and allows you to switch between them. It’s a default applet in Ubuntu-netbook-remix, since on net­books the screen real estate is essential.

It’s a nice lit­tle applet, but unfor­tu­nately does not work well with ver­ti­cal pan­els, since it tries to dis­play the icon list of the run­ning appli­ca­tions hor­i­zon­tally (see this bug). I’ve devel­oped a patch to window-picker-applet-0.4.22 that solves this issue.
To use it, do as follows:

apt-get source  window-picker-applet
cd window-picker-applet-0.4.22
patch -p1 < $PATH_TO_THE_PATCH_FILE

and then the usual:

./configure
cd src && make && sudo make install
killall gnome-panel

Note that this patch *needs* gnome-panel to be restarted, since the panel ori­en­ta­tion is cho­sen at ini­tial­iza­tion (I’ve not imple­mented yet the ori­en­ta­tion change dur­ing execution).

Down­load the patch from here.

, ,

No Comments

Fun with ptrace: system emulation

penguin_internals The more I explore the inter­faces deeply hid­den in the linux ker­nel, the more a new world of oppor­tu­nity opens. Today, while tak­ing a look at the ptrace API, I found out the PTRACE_SYSEMU option.

But what is ptrace? It’s a ker­nel inter­face to check and manip­u­late the infor­ma­tion that crosses the user space-kernel space fron­tier. Its main... prin­ci­pal... only user is gdb usu­ally. The PTRACE_SYSEMU option is quite pecu­liar, it was imple­mented mainly for the user mode linux project. It allows not only to mon­i­tor the sys­tem calls invoked by a process, but also to replace the sys­tem call sematics.

So... how could this be use­ful? For exam­ple to exper­i­ment with dif­fer­ent auditing/sandboxing strate­gies, or to build com­patil­ity lay­ers at the sys­tem call level... but who knows what kind of funny things could be done!

, ,

No Comments