cschleiden

because.

Double Angle Brackets

Years of C++ still make me uncomfortable when I see double angle brackets like

GenericType1<GenericType2<SomeClass>>

in C# code (or in newer versions of C++ as well) …

Spotify App auf Windows Phone 7 in Deutschland / Spotify on Windows Phone 7 from Germany

Seit einigen Tagen ist nach langer Wartezeit endlich Spotify fuer das Windows Phone 7 erschienen. Leider, leider wurde die App nicht in den deutschen Marketplace eingestellt. Mit einem kleinen Trick ist es aber trotzdem moeglich, die Spotify App auch aus Deutschland heraus zu nutzen.

Vorraussetzungen

  • Ein ungelocktes Telefon. Am einfachsten mit einem Entwickleraccount, ansonsten ChevronWP oder aehnliches
  • Ein bezahlter Spotify Premium Account

Der Schluessel zur Installation ist ein kleines Tool names Phone7Market. Damit ist es moeglich, die .XAP Pakete fuer kostenlose Apps aus dem Marketplace zu laden. Praktischerweise wird nicht nur der deutsche Marketplace unterstuetzt, sondern auch die anderssprachigen Varianten.

image

Mit einer einfachen Suche im en-US Marketplace nach “Spotify” findet man das entsprechende Paket und es laesst sich aus dem Tool heraus direkt auf dem Device installieren:

image

Abschliessend ist noch zu sagen dass die App hervorragend funktioniert und eine sehr angenehme Metro Oberflaeche zum eigenen Spotify-Profil bereit stellt.

Viel Spass!

Büchermenschen

Als grosser Kindle Fan erzaehlen mir auch Leute staendig von dem tollen Gefuehl ein Buch aus Papier in der Hand zu halten… passend dazu gerade gelesen:

Neben dem wirtschaftlichen haben die Verlage noch ein anderes, ein emotionales Problem. Ein Insider formuliert es brutal: “In den Verlagen sitzen oben oft alte Menschen, die sehr konservativ sind.” Positiver könnte man formulieren: Büchermenschen lieben Bücher, interessieren sich für Papierqualität, Bindung und Typografie.

Quelle: http://www.spiegel.de/netzwelt/gadgets/0,1518,791813,00.html

Reasons why I exit vi

Windows Phone 7.5 Mango und O2 Visual Voice Mail

Seit gestern wird die aktuelle Windows Phone 7 version “Mango” ausgeliefert (rockt uebrigens) und bringt (theoretisch) Support fuer Visual Voice Mail mit. O2 Deutschland Kunden (so wie ich) haben in dieser Hinsicht aber leider Pech, denn ein O2 Mitarbeiter schreibt im O2 Forum:

ja gibt es: Nach derzeitigem Stand wird es Visual Voicemail aus Kostengründen nicht für andere Plattformen als iOS geben. Sobald sich das ändert, werden wir dies rechtzeitig bekanntgeben.

(Quelle: http://forum.o2online.de/t5/Software-Firmware/Visual-Voice-Mail-f%C3%BCr-Windows-Phone-7-Mango/td-p/133754)

Schade.

Linker trouble on BlueGene/P system

Today I have learned that having a global variable in some C89 code which is not declared as static might be problematic if said code is later linked together with a Fortran program which includes a function with the exact same name es the mentioned variable. Somehow the program ended up at the location of the variable which of course ended in a crash with a signal four (illegal instruction). Took me about 12h to find and fix that bug… in my defense it was on a BlueGene system and I first thought the error had something to do with some front-/backend problems (you cross compile on the frontend and then execute the resulting binary using the LoadLeveler)… Anyway, now it works and I can finally take measurements for the thesis.

SIGPROF signal handler and pthreads

During work on my thesis the question popped up how signals generated by the SIGPROF timer were handled in multithreaded code. Signal handlers are process specific to it could have been that one random thread handled the sent signal. As I could not a find a suitable explanation in the intertubes I performed a small experiment.

My sample program installs a signal handler and starts a timer with a frequency of about 100hz. At first the number of captured signals in a ten second timespan are captured using only the main thread and then using four individual threads. The output is:
Signals caught after 10 seconds: 999
Creating 4 threads
Signals caught after 4x10 seconds by thread 0: 1000
Signals caught after 4x10 seconds by thread 1: 1000
Signals caught after 4x10 seconds by thread 2: 1000
Signals caught after 4x10 seconds by thread 3: 1000

So apparently each thread handles the SIGPROF signal, which is quite nice for my purpose.

The sourcode is here (I just assume that pthread_self is async-safe even though it’s specified by the standard. It appears, however, that assuming that is done by most people working on that kind of stuff):

#include <signal.h>
#include <stdio.h>
#include <pthread.h>
#include <sys/time.h>

#include "../../util/util_time_measurement.h"

const int thread_count = 4;

volatile sig_atomic_t signal_count[thread_count];

pthread_t threads[thread_count];

static void sigprof_handler(int sig_nr, siginfo_t* info, void *context)
{
   int t;
   for(t = 0; t < thread_count; ++t)
   {
      if(threads[t] == pthread_self())
      {
	signal_count[t]++;

	return;
      }
   }

   /* Probably no thread */
   signal_count[0]++;
}

void install_signal_handler()
{
   /* Install signal handler for SIGPROF event */
   struct sigaction sa;
   memset(&sa, 0, sizeof(sa));
   sa.sa_sigaction = sigprof_handler;
   sa.sa_flags = SA_RESTART | SA_SIGINFO;
   sigemptyset(&sa.sa_mask);

   sigaction(SIGPROF, &sa, NULL);
}

void idle_time(int seconds)
{
   timestamp_t start = util_get_timestamp();
   while(1)
   {
      if(util_get_timestamp() > start + seconds)
      {
	break;
      }
   }
}

void* thread_work(void* data)
{
   idle_time(10);

   return NULL;
}

int main(int argc, char** argv)
{
   install_signal_handler();
   
   static struct itimerval timer;

   timer.it_interval.tv_sec = 0;
   timer.it_interval.tv_usec = 1000000 / 100; /* 100hz */
   timer.it_value = timer.it_interval;

   /* Reset count */
   int t;
   for(t = 0; t < thread_count; ++t)
   {
      signal_count[t] = 0;
   }

   /* Install timer */
   if (setitimer(ITIMER_PROF, &timer, NULL) != 0)
   {
      printf("Timer could not be initialized \n");
   }
   
   /* Idle for 10 seconds */
   idle_time(10);


   printf("Signals caught after 10 seconds: %d \n", signal_count[0]);

   /* Reset count */
   for(t = 0; t < thread_count; ++t)
   {
      signal_count[t] = 0;
   }

   printf("Creating %d threads... \n", thread_count);

   for(t = 0; t < thread_count; ++t)
   {
      pthread_create(&threads[t], NULL, thread_work, NULL);
   }
   
   for(t = 0; t < thread_count; ++t)
   {
      pthread_join(threads[t], NULL);
   }

   for(t = 0; t < thread_count; ++t)
   {
      printf("Signals caught after %dx10 seconds by thread %d: %d \n", thread_count, t, signal_count[t]);
   }
}

C++ and Beyond 2011: Herb Sutter – Why C++?

Export Multiple Charts from Excel (Office) To PDF For LaTeX Inclusion At Once

I still receive a lot of hits for my earlier post about how to export Excel charts to PDF in order to include them in a LaTeX document. Various keywords also indicate that a lot of people want to kind of automate that process and export many charts at once. Luckily that is also possible now. I have not checked for the PC version yet (if you do it would be great if you could tell me in the comments or view some other channel but here is how-to for Microsoft Excel 2011 for the Mac:

1. Create your charts (that step should be obvious)

2. Select all your charts (hold shift and click):

3. Select “Save as Picture” from the context menu

4. Check the Box “Save each graphic as a separate file” and select format PDF:
 5. Enter a name. Note: The name entered here will result in Excel: a) creating a directory with the name b) saving each selected diagram with name “<entered-name>-<number>.pdf”. So for example “Charts”:
with the two earlier selected charts will result in:
6. All selected charts will be saved and automatically cropped, ready to be included in your document.

7. This works similarly in Microsoft Word and Microsoft Powerpoint.

 

Have fun.

 

Plan for the future

Plan for a sabbatical (yeah, before actually starting a job I make plans for a sabbatical ;) :

Follow

Get every new post delivered to your Inbox.

Join 198 other followers