1
0
Fork 0
forked from len0rd/rockbox

All kernel objects in code shared amongs targets (core, plugins, codecs) should be declared SHAREDBSS_ATTR as any core could potentially touch them even though they seem only to involve threads on one core. The exception is target code for particular CPUs where proper allocation is fixed. playlist.c was a little odd too-- use one mutex for the current playlist and a separate one for created playlists (still pondering the necessity of more than one).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29305 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2011-02-14 11:27:45 +00:00
parent 8f14357064
commit b15aa47c56
18 changed files with 44 additions and 37 deletions

View file

@ -176,8 +176,8 @@ static void buffering_thread(void);
static long buffering_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)]; static long buffering_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)];
static const char buffering_thread_name[] = "buffering"; static const char buffering_thread_name[] = "buffering";
static unsigned int buffering_thread_id = 0; static unsigned int buffering_thread_id = 0;
static struct event_queue buffering_queue; static struct event_queue buffering_queue SHAREDBSS_ATTR;
static struct queue_sender_list buffering_queue_sender_list; static struct queue_sender_list buffering_queue_sender_list SHAREDBSS_ATTR;

View file

@ -81,15 +81,15 @@ extern bool automatic_skip; /* Who initiated in-progress skip? (C/A-) */
*/ */
static bool codec_requested_stop = false; static bool codec_requested_stop = false;
extern struct event_queue audio_queue; extern struct event_queue audio_queue SHAREDBSS_ATTR;
extern struct event_queue codec_queue; extern struct event_queue codec_queue SHAREDBSS_ATTR;
extern struct codec_api ci; /* from codecs.c */ extern struct codec_api ci; /* from codecs.c */
/* Codec thread */ /* Codec thread */
unsigned int codec_thread_id; /* For modifying thread priority later. unsigned int codec_thread_id; /* For modifying thread priority later.
Used by playback.c and pcmbuf.c */ Used by playback.c and pcmbuf.c */
static struct queue_sender_list codec_queue_sender_list; static struct queue_sender_list codec_queue_sender_list SHAREDBSS_ATTR;
static long codec_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)] static long codec_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)]
IBSS_ATTR; IBSS_ATTR;
static const char codec_thread_name[] = "codec"; static const char codec_thread_name[] = "codec";

View file

@ -150,7 +150,7 @@ static char mpeg_stack[DEFAULT_STACK_SIZE];
static struct mp3entry taginfo; static struct mp3entry taginfo;
#else /* !SIMULATOR */ #else /* !SIMULATOR */
static struct event_queue mpeg_queue; static struct event_queue mpeg_queue SHAREDBSS_ATTR;
static long mpeg_stack[(DEFAULT_STACK_SIZE + 0x1000)/sizeof(long)]; static long mpeg_stack[(DEFAULT_STACK_SIZE + 0x1000)/sizeof(long)];
static int audiobuflen; static int audiobuflen;

View file

@ -192,11 +192,14 @@ static int rotate_index(const struct playlist_info* playlist, int index);
#ifdef HAVE_DIRCACHE #ifdef HAVE_DIRCACHE
#define PLAYLIST_LOAD_POINTERS 1 #define PLAYLIST_LOAD_POINTERS 1
static struct event_queue playlist_queue; static struct event_queue playlist_queue SHAREDBSS_ATTR;
static long playlist_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)]; static long playlist_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)];
static const char playlist_thread_name[] = "playlist cachectrl"; static const char playlist_thread_name[] = "playlist cachectrl";
#endif #endif
static struct mutex current_playlist_mutex SHAREDBSS_ATTR;
static struct mutex created_playlist_mutex SHAREDBSS_ATTR;
/* Check if the filename suggests M3U or M3U8 format. */ /* Check if the filename suggests M3U or M3U8 format. */
static bool is_m3u8(const char* filename) static bool is_m3u8(const char* filename)
{ {
@ -1232,9 +1235,9 @@ static void playlist_flush_callback(void *param)
{ {
if (playlist->num_cached > 0) if (playlist->num_cached > 0)
{ {
mutex_lock(&playlist->control_mutex); mutex_lock(playlist->control_mutex);
flush_cached_control(playlist); flush_cached_control(playlist);
mutex_unlock(&playlist->control_mutex); mutex_unlock(playlist->control_mutex);
} }
sync_control(playlist, true); sync_control(playlist, true);
} }
@ -1362,7 +1365,7 @@ static int get_filename(struct playlist_info* playlist, int index, int seek,
} }
else if (max < 0) else if (max < 0)
{ {
mutex_lock(&playlist->control_mutex); mutex_lock(playlist->control_mutex);
if (control_file) if (control_file)
{ {
@ -1396,7 +1399,7 @@ static int get_filename(struct playlist_info* playlist, int index, int seek,
} }
} }
mutex_unlock(&playlist->control_mutex); mutex_unlock(playlist->control_mutex);
if (max < 0) if (max < 0)
{ {
@ -1829,7 +1832,7 @@ static int update_control(struct playlist_info* playlist,
struct playlist_control_cache* cache; struct playlist_control_cache* cache;
bool flush = false; bool flush = false;
mutex_lock(&playlist->control_mutex); mutex_lock(playlist->control_mutex);
cache = &(playlist->control_cache[playlist->num_cached++]); cache = &(playlist->control_cache[playlist->num_cached++]);
@ -1861,7 +1864,7 @@ static int update_control(struct playlist_info* playlist,
if (flush || playlist->num_cached == PLAYLIST_MAX_CACHE) if (flush || playlist->num_cached == PLAYLIST_MAX_CACHE)
result = flush_cached_control(playlist); result = flush_cached_control(playlist);
mutex_unlock(&playlist->control_mutex); mutex_unlock(playlist->control_mutex);
return result; return result;
} }
@ -1881,10 +1884,10 @@ static void sync_control(struct playlist_info* playlist, bool force)
{ {
if (playlist->pending_control_sync) if (playlist->pending_control_sync)
{ {
mutex_lock(&playlist->control_mutex); mutex_lock(playlist->control_mutex);
fsync(playlist->control_fd); fsync(playlist->control_fd);
playlist->pending_control_sync = false; playlist->pending_control_sync = false;
mutex_unlock(&playlist->control_mutex); mutex_unlock(playlist->control_mutex);
} }
} }
} }
@ -1908,6 +1911,9 @@ void playlist_init(void)
{ {
struct playlist_info* playlist = &current_playlist; struct playlist_info* playlist = &current_playlist;
mutex_init(&current_playlist_mutex);
mutex_init(&created_playlist_mutex);
playlist->current = true; playlist->current = true;
strlcpy(playlist->control_filename, PLAYLIST_CONTROL_FILE, strlcpy(playlist->control_filename, PLAYLIST_CONTROL_FILE,
sizeof(playlist->control_filename)); sizeof(playlist->control_filename));
@ -1919,7 +1925,8 @@ void playlist_init(void)
playlist->buffer_size = playlist->buffer_size =
AVERAGE_FILENAME_LENGTH * global_settings.max_files_in_dir; AVERAGE_FILENAME_LENGTH * global_settings.max_files_in_dir;
playlist->buffer = buffer_alloc(playlist->buffer_size); playlist->buffer = buffer_alloc(playlist->buffer_size);
mutex_init(&playlist->control_mutex); playlist->control_mutex = &current_playlist_mutex;
empty_playlist(playlist, true); empty_playlist(playlist, true);
#ifdef HAVE_DIRCACHE #ifdef HAVE_DIRCACHE
@ -1943,14 +1950,14 @@ void playlist_shutdown(void)
if (playlist->control_fd >= 0) if (playlist->control_fd >= 0)
{ {
mutex_lock(&playlist->control_mutex); mutex_lock(playlist->control_mutex);
if (playlist->num_cached > 0) if (playlist->num_cached > 0)
flush_cached_control(playlist); flush_cached_control(playlist);
close(playlist->control_fd); close(playlist->control_fd);
mutex_unlock(&playlist->control_mutex); mutex_unlock(playlist->control_mutex);
} }
} }
@ -2705,7 +2712,7 @@ int playlist_create_ex(struct playlist_info* playlist,
playlist->buffer_size = 0; playlist->buffer_size = 0;
playlist->buffer = NULL; playlist->buffer = NULL;
mutex_init(&playlist->control_mutex); playlist->control_mutex = &created_playlist_mutex;
} }
new_playlist(playlist, dir, file); new_playlist(playlist, dir, file);
@ -3441,7 +3448,7 @@ int playlist_save(struct playlist_info* playlist, char *filename)
{ {
result = -1; result = -1;
mutex_lock(&playlist->control_mutex); mutex_lock(playlist->control_mutex);
/* Replace the current playlist with the new one and update indices */ /* Replace the current playlist with the new one and update indices */
close(playlist->fd); close(playlist->fd);
@ -3471,7 +3478,7 @@ int playlist_save(struct playlist_info* playlist, char *filename)
} }
} }
mutex_unlock(&playlist->control_mutex); mutex_unlock(playlist->control_mutex);
} }

View file

@ -105,7 +105,7 @@ struct playlist_info
int num_cached; /* number of cached entries */ int num_cached; /* number of cached entries */
bool pending_control_sync; /* control file needs to be synced */ bool pending_control_sync; /* control file needs to be synced */
struct mutex control_mutex; /* mutex for control file access */ struct mutex *control_mutex; /* mutex for control file access */
int last_shuffled_start; /* number of tracks when insert last int last_shuffled_start; /* number of tracks when insert last
shuffled command start */ shuffled command start */
}; };

View file

@ -266,7 +266,7 @@ static struct batt_info
#define BUF_ELEMENTS (sizeof(bat)/sizeof(struct batt_info)) #define BUF_ELEMENTS (sizeof(bat)/sizeof(struct batt_info))
static unsigned int thread_id; static unsigned int thread_id;
static struct event_queue thread_q; static struct event_queue thread_q SHAREDBSS_ATTR;
static bool in_usb_mode; static bool in_usb_mode;
static unsigned int buf_idx; static unsigned int buf_idx;

View file

@ -31,7 +31,7 @@
#define EV_EXIT 9999 #define EV_EXIT 9999
#define THREAD_STACK_SIZE DEFAULT_STACK_SIZE + 0x200 #define THREAD_STACK_SIZE DEFAULT_STACK_SIZE + 0x200
static unsigned int thread_id; static unsigned int thread_id;
static struct event_queue thread_q; static struct event_queue thread_q SHAREDBSS_ATTR;
/* use long for aligning */ /* use long for aligning */
unsigned long thread_stack[THREAD_STACK_SIZE/sizeof(long)]; unsigned long thread_stack[THREAD_STACK_SIZE/sizeof(long)];
#endif #endif

View file

@ -96,7 +96,7 @@
#ifndef __PCTOOL__ #ifndef __PCTOOL__
/* Tag Cache thread. */ /* Tag Cache thread. */
static struct event_queue tagcache_queue; static struct event_queue tagcache_queue SHAREDBSS_ATTR;
static long tagcache_stack[(DEFAULT_STACK_SIZE + 0x4000)/sizeof(long)]; static long tagcache_stack[(DEFAULT_STACK_SIZE + 0x4000)/sizeof(long)];
static const char tagcache_thread_name[] = "tagcache"; static const char tagcache_thread_name[] = "tagcache";
#endif #endif
@ -159,7 +159,7 @@ struct tagcache_command_entry {
static struct tagcache_command_entry command_queue[TAGCACHE_COMMAND_QUEUE_LENGTH]; static struct tagcache_command_entry command_queue[TAGCACHE_COMMAND_QUEUE_LENGTH];
static volatile int command_queue_widx = 0; static volatile int command_queue_widx = 0;
static volatile int command_queue_ridx = 0; static volatile int command_queue_ridx = 0;
static struct mutex command_queue_mutex; static struct mutex command_queue_mutex SHAREDBSS_ATTR;
#endif #endif
/* Tag database structures. */ /* Tag database structures. */

View file

@ -95,7 +95,7 @@ enum {
static void backlight_thread(void); static void backlight_thread(void);
static long backlight_stack[DEFAULT_STACK_SIZE/sizeof(long)]; static long backlight_stack[DEFAULT_STACK_SIZE/sizeof(long)];
static const char backlight_thread_name[] = "backlight"; static const char backlight_thread_name[] = "backlight";
static struct event_queue backlight_queue; static struct event_queue backlight_queue SHAREDBSS_ATTR;
#ifdef BACKLIGHT_DRIVER_CLOSE #ifdef BACKLIGHT_DRIVER_CLOSE
static unsigned int backlight_thread_id = 0; static unsigned int backlight_thread_id = 0;
#endif #endif

View file

@ -74,7 +74,7 @@ static unsigned long reserve_used = 0;
static unsigned int cache_build_ticks = 0; static unsigned int cache_build_ticks = 0;
static unsigned long appflags = 0; static unsigned long appflags = 0;
static struct event_queue dircache_queue; static struct event_queue dircache_queue SHAREDBSS_ATTR;
static long dircache_stack[(DEFAULT_STACK_SIZE + 0x400)/sizeof(long)]; static long dircache_stack[(DEFAULT_STACK_SIZE + 0x400)/sizeof(long)];
static const char dircache_thread_name[] = "dircache"; static const char dircache_thread_name[] = "dircache";

View file

@ -90,7 +90,7 @@ static long last_disk_activity = -1;
/* private variables */ /* private variables */
static struct mutex mmc_mutex; static struct mutex mmc_mutex SHAREDBSS_ATTR;
#ifdef HAVE_HOTSWAP #ifdef HAVE_HOTSWAP
static long mmc_stack[((DEFAULT_STACK_SIZE*2) + 0x800)/sizeof(long)]; static long mmc_stack[((DEFAULT_STACK_SIZE*2) + 0x800)/sizeof(long)];
@ -98,7 +98,7 @@ static long mmc_stack[((DEFAULT_STACK_SIZE*2) + 0x800)/sizeof(long)];
static long mmc_stack[(DEFAULT_STACK_SIZE*2)/sizeof(long)]; static long mmc_stack[(DEFAULT_STACK_SIZE*2)/sizeof(long)];
#endif #endif
static const char mmc_thread_name[] = "mmc"; static const char mmc_thread_name[] = "mmc";
static struct event_queue mmc_queue; static struct event_queue mmc_queue SHAREDBSS_ATTR;
static bool initialized = false; static bool initialized = false;
static bool new_mmc_circuit; static bool new_mmc_circuit;

View file

@ -42,7 +42,7 @@
#include "lcd-remote.h" #include "lcd-remote.h"
#endif #endif
struct event_queue button_queue; struct event_queue button_queue SHAREDBSS_ATTR;
static long lastbtn; /* Last valid button status */ static long lastbtn; /* Last valid button status */
static long last_read; /* Last button status, for debouncing/filtering */ static long last_read; /* Last button status, for debouncing/filtering */

View file

@ -54,7 +54,7 @@
/* arbitrary delay loop */ /* arbitrary delay loop */
#define DELAY do { int _x; for(_x=0;_x<20;_x++);} while (0) #define DELAY do { int _x; for(_x=0;_x<20;_x++);} while (0)
static struct mutex i2c_mtx; static struct mutex i2c_mtx SHAREDBSS_ATTR;
void i2c_begin(void) void i2c_begin(void)
{ {

View file

@ -49,7 +49,7 @@ static struct scrollinfo lcd_scroll[LCD_SCROLLABLE_LINES];
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD
static struct scrollinfo lcd_remote_scroll[LCD_REMOTE_SCROLLABLE_LINES]; static struct scrollinfo lcd_remote_scroll[LCD_REMOTE_SCROLLABLE_LINES];
static struct event_queue scroll_queue; static struct event_queue scroll_queue SHAREDBSS_ATTR;
#endif #endif
struct scroll_screen_info lcd_scroll_info = struct scroll_screen_info lcd_scroll_info =

View file

@ -182,7 +182,7 @@ static struct sd_card_status sd_status[NUM_DRIVES] =
static long sd_stack [(DEFAULT_STACK_SIZE*2 + 0x1c0)/sizeof(long)]; static long sd_stack [(DEFAULT_STACK_SIZE*2 + 0x1c0)/sizeof(long)];
static const char sd_thread_name[] = "ata/sd"; static const char sd_thread_name[] = "ata/sd";
static struct mutex sd_mtx SHAREDBSS_ATTR; static struct mutex sd_mtx SHAREDBSS_ATTR;
static struct event_queue sd_queue; static struct event_queue sd_queue SHAREDBSS_ATTR;
#ifdef HAVE_HOTSWAP #ifdef HAVE_HOTSWAP
static int sd_first_drive = 0; static int sd_first_drive = 0;

View file

@ -288,7 +288,7 @@ bool filling; /* We are filling the buffer with data from disk */
struct event_queue mpeg_queue; struct event_queue mpeg_queue SHAREDBSS_ATTR;

View file

@ -31,7 +31,7 @@ unsigned int s2[256];
void t1(void); void t1(void);
void t2(void); void t2(void);
struct event_queue main_q; struct event_queue main_q SHAREDBSS_ATTR;
int tick_add_task(void (*f)(void)); int tick_add_task(void (*f)(void));

View file

@ -82,7 +82,7 @@ static const char usb_thread_name[] = "usb";
static unsigned int usb_thread_entry = 0; static unsigned int usb_thread_entry = 0;
static bool usb_monitor_enabled = false; static bool usb_monitor_enabled = false;
#endif /* USB_FULL_INIT */ #endif /* USB_FULL_INIT */
static struct event_queue usb_queue; static struct event_queue usb_queue SHAREDBSS_ATTR;
static bool exclusive_storage_access = false; static bool exclusive_storage_access = false;
#ifdef USB_ENABLE_HID #ifdef USB_ENABLE_HID
static bool usb_hid = true; static bool usb_hid = true;