summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-02-14 11:27:45 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-02-14 11:27:45 +0000
commitb15aa47c56d4f8c6e4bf83fef48e7a764dd119a2 (patch)
tree90e95627f56397cb74e021269a3cb65dd4c6ba2c /apps
parent8f14357064d1b8734e2f4dbe2708ace26d5134d1 (diff)
downloadrockbox-b15aa47c56d4f8c6e4bf83fef48e7a764dd119a2.tar.gz
rockbox-b15aa47c56d4f8c6e4bf83fef48e7a764dd119a2.zip
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
Diffstat (limited to 'apps')
-rw-r--r--apps/buffering.c4
-rw-r--r--apps/codec_thread.c6
-rw-r--r--apps/mpeg.c2
-rw-r--r--apps/playlist.c37
-rw-r--r--apps/playlist.h2
-rw-r--r--apps/plugins/battery_bench.c2
-rw-r--r--apps/plugins/mikmod/mikmod.c2
-rw-r--r--apps/tagcache.c4
8 files changed, 33 insertions, 26 deletions
diff --git a/apps/buffering.c b/apps/buffering.c
index cbc47c63e7..54c6c05baa 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -176,8 +176,8 @@ static void buffering_thread(void);
176static long buffering_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)]; 176static long buffering_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)];
177static const char buffering_thread_name[] = "buffering"; 177static const char buffering_thread_name[] = "buffering";
178static unsigned int buffering_thread_id = 0; 178static unsigned int buffering_thread_id = 0;
179static struct event_queue buffering_queue; 179static struct event_queue buffering_queue SHAREDBSS_ATTR;
180static struct queue_sender_list buffering_queue_sender_list; 180static struct queue_sender_list buffering_queue_sender_list SHAREDBSS_ATTR;
181 181
182 182
183 183
diff --git a/apps/codec_thread.c b/apps/codec_thread.c
index ef02f70811..03ab5622e2 100644
--- a/apps/codec_thread.c
+++ b/apps/codec_thread.c
@@ -81,15 +81,15 @@ extern bool automatic_skip; /* Who initiated in-progress skip? (C/A-) */
81 */ 81 */
82static bool codec_requested_stop = false; 82static bool codec_requested_stop = false;
83 83
84extern struct event_queue audio_queue; 84extern struct event_queue audio_queue SHAREDBSS_ATTR;
85extern struct event_queue codec_queue; 85extern struct event_queue codec_queue SHAREDBSS_ATTR;
86 86
87extern struct codec_api ci; /* from codecs.c */ 87extern struct codec_api ci; /* from codecs.c */
88 88
89/* Codec thread */ 89/* Codec thread */
90unsigned int codec_thread_id; /* For modifying thread priority later. 90unsigned int codec_thread_id; /* For modifying thread priority later.
91 Used by playback.c and pcmbuf.c */ 91 Used by playback.c and pcmbuf.c */
92static struct queue_sender_list codec_queue_sender_list; 92static struct queue_sender_list codec_queue_sender_list SHAREDBSS_ATTR;
93static long codec_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)] 93static long codec_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)]
94IBSS_ATTR; 94IBSS_ATTR;
95static const char codec_thread_name[] = "codec"; 95static const char codec_thread_name[] = "codec";
diff --git a/apps/mpeg.c b/apps/mpeg.c
index bdca92048f..690e530d9b 100644
--- a/apps/mpeg.c
+++ b/apps/mpeg.c
@@ -150,7 +150,7 @@ static char mpeg_stack[DEFAULT_STACK_SIZE];
150static struct mp3entry taginfo; 150static struct mp3entry taginfo;
151 151
152#else /* !SIMULATOR */ 152#else /* !SIMULATOR */
153static struct event_queue mpeg_queue; 153static struct event_queue mpeg_queue SHAREDBSS_ATTR;
154static long mpeg_stack[(DEFAULT_STACK_SIZE + 0x1000)/sizeof(long)]; 154static long mpeg_stack[(DEFAULT_STACK_SIZE + 0x1000)/sizeof(long)];
155 155
156static int audiobuflen; 156static int audiobuflen;
diff --git a/apps/playlist.c b/apps/playlist.c
index 41d6ae5ed7..6f6db27b2a 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -192,11 +192,14 @@ static int rotate_index(const struct playlist_info* playlist, int index);
192#ifdef HAVE_DIRCACHE 192#ifdef HAVE_DIRCACHE
193#define PLAYLIST_LOAD_POINTERS 1 193#define PLAYLIST_LOAD_POINTERS 1
194 194
195static struct event_queue playlist_queue; 195static struct event_queue playlist_queue SHAREDBSS_ATTR;
196static long playlist_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)]; 196static long playlist_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)];
197static const char playlist_thread_name[] = "playlist cachectrl"; 197static const char playlist_thread_name[] = "playlist cachectrl";
198#endif 198#endif
199 199
200static struct mutex current_playlist_mutex SHAREDBSS_ATTR;
201static struct mutex created_playlist_mutex SHAREDBSS_ATTR;
202
200/* Check if the filename suggests M3U or M3U8 format. */ 203/* Check if the filename suggests M3U or M3U8 format. */
201static bool is_m3u8(const char* filename) 204static bool is_m3u8(const char* filename)
202{ 205{
@@ -1232,9 +1235,9 @@ static void playlist_flush_callback(void *param)
1232 { 1235 {
1233 if (playlist->num_cached > 0) 1236 if (playlist->num_cached > 0)
1234 { 1237 {
1235 mutex_lock(&playlist->control_mutex); 1238 mutex_lock(playlist->control_mutex);
1236 flush_cached_control(playlist); 1239 flush_cached_control(playlist);
1237 mutex_unlock(&playlist->control_mutex); 1240 mutex_unlock(playlist->control_mutex);
1238 } 1241 }
1239 sync_control(playlist, true); 1242 sync_control(playlist, true);
1240 } 1243 }
@@ -1362,7 +1365,7 @@ static int get_filename(struct playlist_info* playlist, int index, int seek,
1362 } 1365 }
1363 else if (max < 0) 1366 else if (max < 0)
1364 { 1367 {
1365 mutex_lock(&playlist->control_mutex); 1368 mutex_lock(playlist->control_mutex);
1366 1369
1367 if (control_file) 1370 if (control_file)
1368 { 1371 {
@@ -1396,7 +1399,7 @@ static int get_filename(struct playlist_info* playlist, int index, int seek,
1396 } 1399 }
1397 } 1400 }
1398 1401
1399 mutex_unlock(&playlist->control_mutex); 1402 mutex_unlock(playlist->control_mutex);
1400 1403
1401 if (max < 0) 1404 if (max < 0)
1402 { 1405 {
@@ -1829,7 +1832,7 @@ static int update_control(struct playlist_info* playlist,
1829 struct playlist_control_cache* cache; 1832 struct playlist_control_cache* cache;
1830 bool flush = false; 1833 bool flush = false;
1831 1834
1832 mutex_lock(&playlist->control_mutex); 1835 mutex_lock(playlist->control_mutex);
1833 1836
1834 cache = &(playlist->control_cache[playlist->num_cached++]); 1837 cache = &(playlist->control_cache[playlist->num_cached++]);
1835 1838
@@ -1861,7 +1864,7 @@ static int update_control(struct playlist_info* playlist,
1861 if (flush || playlist->num_cached == PLAYLIST_MAX_CACHE) 1864 if (flush || playlist->num_cached == PLAYLIST_MAX_CACHE)
1862 result = flush_cached_control(playlist); 1865 result = flush_cached_control(playlist);
1863 1866
1864 mutex_unlock(&playlist->control_mutex); 1867 mutex_unlock(playlist->control_mutex);
1865 1868
1866 return result; 1869 return result;
1867} 1870}
@@ -1881,10 +1884,10 @@ static void sync_control(struct playlist_info* playlist, bool force)
1881 { 1884 {
1882 if (playlist->pending_control_sync) 1885 if (playlist->pending_control_sync)
1883 { 1886 {
1884 mutex_lock(&playlist->control_mutex); 1887 mutex_lock(playlist->control_mutex);
1885 fsync(playlist->control_fd); 1888 fsync(playlist->control_fd);
1886 playlist->pending_control_sync = false; 1889 playlist->pending_control_sync = false;
1887 mutex_unlock(&playlist->control_mutex); 1890 mutex_unlock(playlist->control_mutex);
1888 } 1891 }
1889 } 1892 }
1890} 1893}
@@ -1908,6 +1911,9 @@ void playlist_init(void)
1908{ 1911{
1909 struct playlist_info* playlist = &current_playlist; 1912 struct playlist_info* playlist = &current_playlist;
1910 1913
1914 mutex_init(&current_playlist_mutex);
1915 mutex_init(&created_playlist_mutex);
1916
1911 playlist->current = true; 1917 playlist->current = true;
1912 strlcpy(playlist->control_filename, PLAYLIST_CONTROL_FILE, 1918 strlcpy(playlist->control_filename, PLAYLIST_CONTROL_FILE,
1913 sizeof(playlist->control_filename)); 1919 sizeof(playlist->control_filename));
@@ -1919,7 +1925,8 @@ void playlist_init(void)
1919 playlist->buffer_size = 1925 playlist->buffer_size =
1920 AVERAGE_FILENAME_LENGTH * global_settings.max_files_in_dir; 1926 AVERAGE_FILENAME_LENGTH * global_settings.max_files_in_dir;
1921 playlist->buffer = buffer_alloc(playlist->buffer_size); 1927 playlist->buffer = buffer_alloc(playlist->buffer_size);
1922 mutex_init(&playlist->control_mutex); 1928 playlist->control_mutex = &current_playlist_mutex;
1929
1923 empty_playlist(playlist, true); 1930 empty_playlist(playlist, true);
1924 1931
1925#ifdef HAVE_DIRCACHE 1932#ifdef HAVE_DIRCACHE
@@ -1943,14 +1950,14 @@ void playlist_shutdown(void)
1943 1950
1944 if (playlist->control_fd >= 0) 1951 if (playlist->control_fd >= 0)
1945 { 1952 {
1946 mutex_lock(&playlist->control_mutex); 1953 mutex_lock(playlist->control_mutex);
1947 1954
1948 if (playlist->num_cached > 0) 1955 if (playlist->num_cached > 0)
1949 flush_cached_control(playlist); 1956 flush_cached_control(playlist);
1950 1957
1951 close(playlist->control_fd); 1958 close(playlist->control_fd);
1952 1959
1953 mutex_unlock(&playlist->control_mutex); 1960 mutex_unlock(playlist->control_mutex);
1954 } 1961 }
1955} 1962}
1956 1963
@@ -2705,7 +2712,7 @@ int playlist_create_ex(struct playlist_info* playlist,
2705 2712
2706 playlist->buffer_size = 0; 2713 playlist->buffer_size = 0;
2707 playlist->buffer = NULL; 2714 playlist->buffer = NULL;
2708 mutex_init(&playlist->control_mutex); 2715 playlist->control_mutex = &created_playlist_mutex;
2709 } 2716 }
2710 2717
2711 new_playlist(playlist, dir, file); 2718 new_playlist(playlist, dir, file);
@@ -3441,7 +3448,7 @@ int playlist_save(struct playlist_info* playlist, char *filename)
3441 { 3448 {
3442 result = -1; 3449 result = -1;
3443 3450
3444 mutex_lock(&playlist->control_mutex); 3451 mutex_lock(playlist->control_mutex);
3445 3452
3446 /* Replace the current playlist with the new one and update indices */ 3453 /* Replace the current playlist with the new one and update indices */
3447 close(playlist->fd); 3454 close(playlist->fd);
@@ -3471,7 +3478,7 @@ int playlist_save(struct playlist_info* playlist, char *filename)
3471 } 3478 }
3472 } 3479 }
3473 3480
3474 mutex_unlock(&playlist->control_mutex); 3481 mutex_unlock(playlist->control_mutex);
3475 3482
3476 } 3483 }
3477 3484
diff --git a/apps/playlist.h b/apps/playlist.h
index fb30b7ac8c..9c45769981 100644
--- a/apps/playlist.h
+++ b/apps/playlist.h
@@ -105,7 +105,7 @@ struct playlist_info
105 int num_cached; /* number of cached entries */ 105 int num_cached; /* number of cached entries */
106 bool pending_control_sync; /* control file needs to be synced */ 106 bool pending_control_sync; /* control file needs to be synced */
107 107
108 struct mutex control_mutex; /* mutex for control file access */ 108 struct mutex *control_mutex; /* mutex for control file access */
109 int last_shuffled_start; /* number of tracks when insert last 109 int last_shuffled_start; /* number of tracks when insert last
110 shuffled command start */ 110 shuffled command start */
111}; 111};
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c
index 044db9ff1f..6a0493ceaa 100644
--- a/apps/plugins/battery_bench.c
+++ b/apps/plugins/battery_bench.c
@@ -266,7 +266,7 @@ static struct batt_info
266#define BUF_ELEMENTS (sizeof(bat)/sizeof(struct batt_info)) 266#define BUF_ELEMENTS (sizeof(bat)/sizeof(struct batt_info))
267 267
268static unsigned int thread_id; 268static unsigned int thread_id;
269static struct event_queue thread_q; 269static struct event_queue thread_q SHAREDBSS_ATTR;
270static bool in_usb_mode; 270static bool in_usb_mode;
271static unsigned int buf_idx; 271static unsigned int buf_idx;
272 272
diff --git a/apps/plugins/mikmod/mikmod.c b/apps/plugins/mikmod/mikmod.c
index fe1768376e..c99d11d636 100644
--- a/apps/plugins/mikmod/mikmod.c
+++ b/apps/plugins/mikmod/mikmod.c
@@ -31,7 +31,7 @@
31#define EV_EXIT 9999 31#define EV_EXIT 9999
32#define THREAD_STACK_SIZE DEFAULT_STACK_SIZE + 0x200 32#define THREAD_STACK_SIZE DEFAULT_STACK_SIZE + 0x200
33static unsigned int thread_id; 33static unsigned int thread_id;
34static struct event_queue thread_q; 34static struct event_queue thread_q SHAREDBSS_ATTR;
35/* use long for aligning */ 35/* use long for aligning */
36unsigned long thread_stack[THREAD_STACK_SIZE/sizeof(long)]; 36unsigned long thread_stack[THREAD_STACK_SIZE/sizeof(long)];
37#endif 37#endif
diff --git a/apps/tagcache.c b/apps/tagcache.c
index ae7199ffd6..ea7768139b 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -96,7 +96,7 @@
96 96
97#ifndef __PCTOOL__ 97#ifndef __PCTOOL__
98/* Tag Cache thread. */ 98/* Tag Cache thread. */
99static struct event_queue tagcache_queue; 99static struct event_queue tagcache_queue SHAREDBSS_ATTR;
100static long tagcache_stack[(DEFAULT_STACK_SIZE + 0x4000)/sizeof(long)]; 100static long tagcache_stack[(DEFAULT_STACK_SIZE + 0x4000)/sizeof(long)];
101static const char tagcache_thread_name[] = "tagcache"; 101static const char tagcache_thread_name[] = "tagcache";
102#endif 102#endif
@@ -159,7 +159,7 @@ struct tagcache_command_entry {
159static struct tagcache_command_entry command_queue[TAGCACHE_COMMAND_QUEUE_LENGTH]; 159static struct tagcache_command_entry command_queue[TAGCACHE_COMMAND_QUEUE_LENGTH];
160static volatile int command_queue_widx = 0; 160static volatile int command_queue_widx = 0;
161static volatile int command_queue_ridx = 0; 161static volatile int command_queue_ridx = 0;
162static struct mutex command_queue_mutex; 162static struct mutex command_queue_mutex SHAREDBSS_ATTR;
163#endif 163#endif
164 164
165/* Tag database structures. */ 165/* Tag database structures. */